error in npm install inspite of changing the file Bson
Asked Answered
X

4

2

using mongodb3.0, node 0.12.0, npm 2.5.1 on windows 7 integrale, I am trying to read and write data into my database, but i have this error in npm intsall!

{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }

js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }

js-bson: Failed to load c++ bson extension, using pure JS version

i tried to replace

bson = require('../build/Release/bson');

into

bson = require('../browser_build/bson');

but i had errors like this:

 exports.BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0 TypeError: Cannot set property       'BSON_BINARY_SUBTYPE_DEFAULT' of undefined  

i am using monk, anfd i have run npm mongodb, npm monk

Xanthe answered 24/3, 2015 at 16:49 Comment(2)
Does the code run anyway with the first error? I've received that error too, but it hasn't affected the code.Apparitor
sure it doesn't affect rest of your code but it is really unpleasant. In my case everything used to work until i run npm updateCoel
D
6

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.

Downpipe answered 24/3, 2015 at 16:49 Comment(6)
This is the only thing that helps me. I spent about 4h with dancing around this problem. Finaly, the problem was with the node (0.12.3 x64) which didn't recognize bson.node as a module. When I reinstall all this stuff (node, python) with x32 versions, the problem is gone.Leomaleon
I had this problem for 2 days. And after a lot of research I found this solution here on stackoverflow. But it was not explained in detail. So I chose to post this answer. Good luck. (y)Ayurveda
i suspect the lastest version of node coz everything did work well until i run npm update in my x64 nodeCoel
@MarcelDjaman were you using Modules like mongoDB, socket.io with x64 node and were they working fine??Ayurveda
everything works fine expect some little nasty warning messages like js-bon failed to load c++ bson extension...Coel
I have the same warning messages but neither my modules like mongo or socket.io were working nor was my application until I followed those steps!Ayurveda
S
1

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.

Shiverick answered 9/5, 2015 at 22:8 Comment(0)
A
0

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.

Ancient answered 24/3, 2015 at 22:33 Comment(2)
I find bson in the same pathin the directory mongoose, is that ok?Xanthe
It stills have the same error! I tried to run node-gyp rebuild but i have this error : gyp: binding.gyp not found (cwd: C:\Node\test) while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp` failed with exit code: 1 `Xanthe
X
0

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

Xanthe answered 26/3, 2015 at 19:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.