gpt4 book ai didi

javascript - 运行 Node 脚本时出错,找不到模块 'mongodb/node_modules/bson'

转载 作者:行者123 更新时间:2023-12-03 03:11:00 25 4
gpt4 key购买 nike

尝试在 mongoose 的帮助下用员工数据填充 mongo 数据库。当运行为: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"
}
}

最佳答案

您可以直接在包 json 文件中将 mongoose 更改为版本 4.2.9。在编辑器中启动 json 文件并将版本更改为“this”。在您拥有项目文件夹的目录中输入“npm install”。

关于javascript - 运行 Node 脚本时出错,找不到模块 'mongodb/node_modules/bson',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46953363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com