error in npm install inspite of changing the file Bson

自闭症网瘾萝莉.ら 提交于 2019-12-01 01:00:14
Haroon Khan

Problem: Modules like Mongo-DB, Socket.io and other requires node-gyp to compile C/C++ code which Kim also discussed. MSVC++ comes only for 32-bit OS, NOW this is the real problem because if you've install node.js and the other requirments like Python 2.7.3 with the 64-bit versions, then you'll face the problems like I did.

Follow these steps:

  • Uninstall Node.js
  • Uninstall all the Modules including Python
  • Now Install 32-bit versions of all the above uninstalled applications and platforms.
  • Follow all the necessary steps.
  • Now install modules you want to use.

You may see some errors while installing, but don't panic. Try running your application and it will work just fine.

NOTE: This solution is platform specific i.e. for MS Windows.

I'm on windows 8.1, but what I did, was first install python 2.7.9 and also visual studio community edition. Both are needed to compile bson. Then I installed: "npm install -g node-gyp", after that I just deleted the node_modules from my project and did "npm install" again. Solved. When I did the install again I could see the message on the console that said bson was compiling.

MongoDB depends on a few libraries. At some point you would have done:

npm install mongodb --save

One of these dependencies is node-gyp which is needed to compile bson. Importantly, node-gyp requires Python 2.7 and Microsoft Visual Studio to be installed (see installation section of node-gyp). If you don't have Python 2.7 and Visual Studio, then node-gyp will fail to build which means it can't compile bson (causing the initial error).

Navigate to: node_modules\mongodb\node_modules\mongodb-core\node_modules\bson

You should find the builderror.log file with more information about why node-gyp failed to build. Most likely this will be due to Python 2.7 or Visual Studio not being installed.

Here's what I had to do to fix it:

I had the exact same problem as you with the bson module not found error. I also changed the require line as you did and ended up with the same error (exports.BSON...). I then uninstalled monk and mongodb:

npm uninstall mongodb --save
npm uninstall monk --save

Installed Python 2.7 and Microsoft Visual Studio, then installed mongodb and monk again:

npm install mongodb --save
npm install monk --save

This fixed it.

The problem is fixed when i changed the version of node 10.34 and nom 1.4.28

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!