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
I had this issue today (Feb 19th, 2016) and I solved it just by installing the latest version of Mongoose. Try putting this in your package.json:
"mongoose": "~4.4"
Hope that helps. Solved it for me!
While creating setup for www.spotdekho.com
in new windows10
machine, I was unable to run command "nodemon web.js"
due same error
"Error: Cannot find module '../build/Release/bson'"
Got it fixed by below steps :
- Create folder "Release" inside "node_modules\bson\build\" location
- Copy bson.js from "node_modules\bson\browser_build\"
- Paste bson.js inside "node_modules\bson\build\Release" folder.
This will resolve the issue.
PS : I am using mongoose version 4.8.8 .
Thanks :) , hope it helps someone .
find in npm module mongodb ..node_modules\mongodb\node_modules\bson\ext\index.js
and change path to js version in catch block
bson = require('../build/Release/bson');
to bson = require('../browser_build/bson');
try {
// Load the precompiled win32 binary
if(process.platform == "win32" && process.arch == "x64") {
bson = require('./win32/x64/bson');
} else if(process.platform == "win32" && process.arch == "ia32") {
bson = require('./win32/ia32/bson');
} else {
bson = require('../browser_build/bson');
}
} catch(err) {
// Attempt to load the release bson version
try {
bson = require('../browser_build/bson');
} catch (err) {
console.dir(err)
console.error("js-bson: Failed to load c++ bson extension, using pure JS version");
bson = require('../lib/bson/bson');
}
}
Install the latest version of mongodb.
Make sure your package.json is using the latest version of mongodb, then remove node_modules/mongodb and do npm install again. If you didn't use mongodb as a direct dependency, try to find which package is using mongdb. I used:
find . -type f -name package.json | xargs grep mongodb
...
./sails-mongo/package.json: "mongodb": "1.4.26",
...
So I updated ./sails-mongo/package.json to:
"mongodb": "2.1.7",
Then remove node_modules/mongodb and do npm install again. Seems fine now.
I don't like the current suggested way of using
require('../browser_build/bson')
Since looking at ../browser_build/bson.js, a 4k+ lines file, which seem also a "non-native" implementation. So although it won't spit out any complains, it is still "using pure JS version", which means slower performance.
Looking at https://github.com/mongodb/js-bson/issues/145 and https://github.com/mongodb/js-bson/issues/165, it seems like the issue was caused by:
antoniofruci commented on Sep 15, 2015
I just found out that c++ code has been moved out 6 months ago and it is now an optional dependency: bson-ext. Indeed, if you install latest version no error occurs.
So I tried to remove the whole node_modules and still got the same error. And looking at package.json of node_modules/mongodb, its version is still 1.4.26, not latest 2.1.7.
Apparently my mongodb comes as a dependency of another package I installed: sails-mongo. Modifying the package.json of sails-mongo and redoing npm install finally solve the issue.
Deploying Keystone JS CMS I had same error and I think most elegant solution is this:
Install npm-check-updates
:
root@keystonejs:~# npm install -g npm-check-updates
Within your keystone site directory, where package.json
is placed, check dependencies:
debian@keystonejs:~/myproject/manalcjim$ npm-check-updates -u
Then update all packages:
debian@keystonejs:~/myproject/manalcjim$ npm install
And finally if you chose jade
for templates, maybe you will need install jade
module explicitly:
debian@keystonejs:~/myproject/manalcjim$ npm install jade --save
Try this npm install bson
and npm update