错误:找不到模块'mongodb / node_modules / bson'

时间:2017-07-01 05:47:50

标签: node.js mongoose

我使用带有mongoose 4.11的节点8.1.2。在启动应用程序时,我收到了以下错误:

D:\express_learn\LAM>node app.js
module.js:487
    throw err;
    ^

Error: Cannot find module 'mongodb/node_modules/bson'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\express_learn\LAM\node_modules\mongoose\lib\drivers\node-mongodb-native\objectid.js:8:16)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

D:\express_learn\LAM>

我尝试了here

中的以下解决方案
npm install node-gyp -g
npm cache clean
rm -rf node_modules
npm install

但仍然得到同样的错误。

以下是package.json

{
  "name": "learn-about-me",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "dependencies": {
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "^1.6.5",
    "connect-flash": "^0.1.1",
    "cookie-parser": "^1.3.2",
    "ejs": "^1.0.0",
    "express": "^4.15.3",
    "express-session": "^1.7.6",
    "mongoose": "^4.11.0",
    "passport": "^0.2.0",
    "passport-local": "^1.0.0"
  }
}

1 个答案:

答案 0 :(得分:0)

以下是我为解决问题所做的工作

npm cache clean --force
rm -f package-lock.json
node install