I am getting the below error:
{ [Error: Cannot find module \'../build/Release/bson\'] code: \'MODULE_NOT_FOUND\' }
js-bson: Failed to load c++ bson extens
If you are using windows 8.1, you might want to make sure that you are installing your npm modules with the correct visual studio compiler.
I have Visual Studio 2012 installed, this command works for me. (after deleting node_modules dir)
npm install --msvs_version=2012
For some reason, node-gyp is trying to use the incorrect version of Visual Studio compiler. I also noticed that the "npm install" command was printing out a warnings about not node-gyp dependencies when installing the mongodb and mongoose modules.
After using the correct msvs_version, the npm install warnings went away as well as the console warning when running my nodejs app.
You might also want to make sure that you have the correct Python 2.7.X version installed and not Python 3.0.X.
You will also need to make sure that python is in your env path.
This worked for me. Search in your workspace for the text:
"../build/Release/bson"
You will probably find it inside the mongose and monk modules.
Then replace each:
bson = require('../build/Release/bson');
with:
bson = require('bson');
that's all!
Unfortunately, All the above answers are only half right.. Took a long time to figure this out..
Mongoose bson install via npm throws warning and causes the error...
npm install -g node-gyp
git clone https://github.com/mongodb/js-bson.git
cd js-bson
npm install
node-gyp rebuild
This works like magic!!
The problem is when you install mongoose via npm it assumes you have python installed on your windows and tries to build required libraries. Since you do not have python it skips building phase with a warning. But when you start your application, required modules are not there so you get this error.
In order to do things right first install python (version 2.7) on your computer from: https://www.python.org/downloads/ or if u have installed chockolatey just type choco install python2
.
Then make sure your python variable is set. You can set it on command prompt like:
SET python=D:\Python27\python.exe
(Of course you should change the path according to your location of python) Then install node-gyp:
npm install -g node-gyp
Now you can reinstall mongoose or whatever module causing the problem:
npm install mongoose
You will see some yellow lines instead of red ones this time but the error will be gone.
Try npm install mongoose@3.8.23
and also replace
bson = require('../build/Release/bson');
to
bson = require('../browser_build/bson');
in node_modules/bson/ext/index.js
This worked for me:
Go to the file (in your project):
node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.js
and change:
bson = require('../build/Release/bson');
to:
bson = require('bson');
Reference: https://github.com/mongodb/js-bson/issues/118