简体   繁体   English

运行节点脚本时出错,找不到模块'mongodb / node_modules / bson'

[英]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.

相关问题 找不到模块'mongodb / node_modules / bson' - Cannot find module 'mongodb/node_modules/bson' GitLab CI 找不到模块错误(当它在 node_modules 中时) - GitLab CI cannot find module error (when it is in node_modules) 错误:在 ReactJS 项目中运行 npm 后找不到模块“serialize-javascript”,即使它存在于目录 node_modules - Error: Cannot find module 'serialize-javascript' after running npm start in ReactJS project, even though there it exists in directory node_modules 节点 js:错误:找不到模块“mime-types/node_modules/mime-db” - Node js: Error: Cannot find module 'mime-types/node_modules/mime-db' 节点 Nodemon 错误:找不到模块 'C:\\Program Files\\nodejs\\node_modules\\nodemon\\bin\\' - Node Nodemon Error: Cannot find module 'C:\Program Files\nodejs\node_modules\nodemon\bin\' 帆扬起错误'找不到模块'express / node_modules / cookie' - Sails lift error 'Cannot find module 'express/node_modules/cookie' Gatsby - 错误:找不到模块 '..\node_modules\gatsby\dist\utils\babel-loader.js' - Gatsby - Error: Cannot find module '..\node_modules\gatsby\dist\utils\babel-loader.js' 电子在主进程中需要node_modules:错误:找不到模块'linvodb3' - Electron require node_modules in main process: Error: Cannot find module ‘linvodb3’ 节点 Nodemon 错误:找不到模块 'C:\Program Files\Git\node_modules\nodemon\bin\nodemon.js' - Node Nodemon Error: Cannot find module 'C:\Program Files\Git\node_modules\nodemon\bin\nodemon.js' 在 node_modules/ 中使用 ES6 文件运行 Mocha 时出错 - Error when running Mocha with ES6 files in node_modules/
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM