[英]Error when running node script , Cannot find module 'mongodb/node_modules/bson'
Trying to populate a mongo db with Employee data with the help of mongoose. 尝试在mongoose的帮助下用Employee数据填充mongo db。 When running as: node populate_db.js it throws an error saying
以以下身份运行时:节点populate_db.js会引发错误消息
module.js:471
throw err;
^
Error: Cannot find module 'mongodb/node_modules/bson'
not able to check the database value as the database also seems to be empty. 无法检查数据库值,因为数据库似乎也为空。
here is my package.json file : 这是我的package.json文件:
{
"name": "hr",
"version": "1.0.0",
"description": "first node app server",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pereiraryan/domains.git"
},
"keywords": [
"domains"
],
"author": "ryan pereira",
"license": "ISC",
"bugs": {
"url": "https://github.com/pereiraryan/domains/issues"
},
"homepage": "https://github.com/pereiraryan/domains#readme",
"dependencies": {
"async": "^2.5.0",
"mongoose-post-find": "0.0.2",
"colors": "^1.1.2",
"debug": "0.7.4",
"express": "4.2.0",
"mongoose": "^3.8.11"
} ,
"scripts": {
"populate": "node ./bin/populate_db"
}
}
You can change your mongoose to version 4.2.9 right in you package json file. 您可以在打包json文件中将猫鼬更改为版本4.2.9。 Power up your json file in an editor and change the version to 'this'.
在编辑器中打开json文件的电源,然后将版本更改为“ this”。 The type 'npm install' in that directory you have your project folder.
您拥有项目文件夹的目录中的“ npm install”类型。
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
try doing this also 也尝试这样做
do npm install inside node_modules/mongodb.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.