在Mean stack中开发时,我有以下错误:找不到模块' mongojs'
我运行命令:node Server
在Ubuntu上的bash中,我遇到的错误是:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'mongojs'
Require stack:
- /home/nishil/Documents/contactListApp/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/nishil/Documents/contactListApp/server.js:5:15)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/nishil/Documents/contactListApp/server.js' ]
}
如何解决此错误?
I ran command: node server
in bash on Ubuntu and below is the error I got:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'mongojs'
Require stack:
- /home/nishil/Documents/contactListApp/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/nishil/Documents/contactListApp/server.js:5:15)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/nishil/Documents/contactListApp/server.js' ]
}
How can I resolve this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请访问您的软件包。
如果是删除软件包锁。
如果未安装mongojs,则可以使用
npm i mongojs
命令来执行此操作,但我建议请将您的软件包从mongojs更改为 mongodb
因为Mongojs自上过去3年以来没有更新,它已经超过了27年的开放时间从很长的时间开始的问题。
让我知道该解决方案是否适合您。
Please check in your package.json file if mongojs is installed or not.
If it is then remove package-lock.json and remove node_modules folder and install node modules again by npm i.
If mongojs is not installed then you can do that using
npm i mongojs
commandBut i would suggest please change your package from mongojs to mongodb https://www.npmjs.com/package/mongodb
As mongojs is seems outdated its not updated since last 3 years it has 27 open issues since very long.
Let me know if this solutions works for you..
如果要使用Mongojs或任何其他模块,请确保它在包装中。JSON和您在包含包装的该目录中运行纱线安装或NPM安装。如果问题仍然存在,请尝试在此目录中删除Node_modules文件夹,然后尝试运行YARN安装或再次安装NPM。
If you want to use mongojs or any other module, please make sure it's there in package.json and you have run yarn install or npm install in that directory containing the package.json. If the problem still persists, try deleting the node_modules folder in this directory and try running yarn install or npm install again.