如何解决此错误以供使用或降低node.js版本?
表示,我做了
NODE_ENV=production nodemon
或
nodemon
错误
Error: The module '/Users/pinkman/Work/MEAN/node_modules/bson/build/Release/bson.node' was compiled against a different Node.js version using
NODE_MODULE_VERSION 44. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (module.js:672:18)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/pinkman/Work/MEAN/node_modules/bson/ext/index.js:15:10)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
js-bson: Failed to load c++ bson extension, using pure JS version/Users/pinkman/Work/MEAN/node_modules/express/lib/router/route.js:162
throw new Error(msg);
^
Error: Route.get() requires callback functions but got a [object Undefined]
at /Users/pinkman/Work/MEAN/node_modules/express/lib/router/route.js:162:15
at Array.forEach (<anonymous>)
at Route.(anonymous function) [as get] (/Users/pinkman/Work/MEAN/node_modules/express/lib/router/route.js:158:15)
at Function.proto.(anonymous function) [as get] (/Users/pinkman/Work/MEAN/node_modules/express/lib/router/index.js:490:19)
at Object.<anonymous> (/Users/pinkman/Work/MEAN/app_api/routes/index.js:7:8)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/pinkman/Work/MEAN/app.js:10:17)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
[nodemon] app crashed - waiting for file changes before starting...
我尝试了所有关于
的事情npm rebuild & npm install.
没有工作!请帮忙!
请避免这个ext,这是为了逃避更多文本的溢出需求!
答案 0 :(得分:0)
该错误基本上告诉您bson包与您正在运行的任何版本的node.js不兼容。
您可以通过运行
查看项目的哪些软件包已过时 npm outdated
有时,只需更新到最新版本的软件包即可解决这些问题。
警告 盲目更新软件包可能会引入其他问题。确保您首先在源代码管理中拥有package.json
的副本,以便在必要时可以回滚。
首先运行以下命令
npm update
如果这不能解决问题,可能需要删除并重新安装软件包。
npm uninstall bson --save
npm install bson --save