I am using node 8.1.2 with mongoose 4.11. On starting the app, I am getting these errors:
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>
I tried the following solution from here
npm install node-gyp -g
npm cache clean
rm -rf node_modules
npm install
But still getting the same error.
Here is 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"
}
}
Here is what I did to resolve the issue
npm cache clean --force
rm -f package-lock.json
node install
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.