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

navra picture navra · Feb 21, 2015 · Viewed 137.6k times · Source

I am getting the below error:

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

Here are my version details:

  • OS: Windows 7

  • MongoDB: 2.6.5

  • Node: 0.12.0

I have tried these things before I posted the issue here.

  1. I went to \node-modules\mongoose\node-modules\mongodb\node-modules\bson folder and made below change in the binding-gyp file from 'include_dirs': [ '<!(node -e "require(\'nan\')")' ] to 'include_dirs': ["<!(nodejs -p -e \"require('path').dirname(require.resolve('nan'))\")"]

  2. Ran this command npm install -g node-gyp

  3. I've updated the mongoose version to 3.8.21 inside package.json

Nothing works. Please suggest

Answer

anydasa picture anydasa · Mar 8, 2015

Find in npm module mongodb:

..\node_modules\mongodb\node_modules\bson\ext\index.js

Change path to js version in catch block:

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

To:

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

Or copy file in:

..\node_modules\bson\build\Release\bson

From:

..\node_modules\bson\browser_build\bson