运行 节点脚本时出错,找不到模块 'mongodb/node_modules/bson'
Error when running node script , Cannot find module 'mongodb/node_modules/bson'
试图在 mongoose 的帮助下用员工数据填充 mongo 数据库。当 运行 as: node populate_db.js 它抛出一个错误说
module.js:471
throw err;
^
Error: Cannot find module 'mongodb/node_modules/bson'
无法检查数据库值,因为数据库似乎也是空的。
这是我的 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"
}
}
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
尝试这样做
还有
do npm install inside node_modules/mongodb.
您可以在您的包 json 文件中将您的 mongoose 更改为版本 4.2.9。
在编辑器中打开 json 文件并将版本更改为 'this'。该目录中的类型 'npm install' 你有你的项目文件夹。
试图在 mongoose 的帮助下用员工数据填充 mongo 数据库。当 运行 as: node populate_db.js 它抛出一个错误说
module.js:471
throw err;
^
Error: Cannot find module 'mongodb/node_modules/bson'
无法检查数据库值,因为数据库似乎也是空的。
这是我的 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"
}
}
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
尝试这样做 还有
do npm install inside node_modules/mongodb.
您可以在您的包 json 文件中将您的 mongoose 更改为版本 4.2.9。 在编辑器中打开 json 文件并将版本更改为 'this'。该目录中的类型 'npm install' 你有你的项目文件夹。