0

Just installed Mongo, mongodb driver and node. All current stable versions on a Ubuntu 14.04

mongo --version
MongoDB shell version: 3.2.1
node --version
v5.2.0

I'm pretty new to koa/mongo/node so I clone some github repos, but when I run code I always get this error:

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

Similar erros on stackoverflow are for older versions and there was either not clear solution or not working in my case.

How is the workflow? What is this extension for?

I tried reinstalling build-essential and node-gyp but without knowing the reason. Maybe is related to the monk or mongoose version if the projects are "old"?

user2670996
  • 2,654
  • 6
  • 29
  • 45
  • Have you tried some solutions in this question http://stackoverflow.com/questions/21656420/failed-to-load-c-bson-extension – zangw Jan 22 '16 at 14:44

2 Answers2

0

You may be missing some build tools on your system. In that case mongo driver will fallback to using a Javascript version of the bson parser, which is fine for development, but probably not in production.

ospet
  • 62
  • 4
0

Here is the solution:

cp ProjectDirectory/node_modules/monk/node_modules/mongodb/node_modules/bson/browser_build/bson.js ProjectDirectory/node_modules/monk/node_modules/mongodb/node_modules/bson/build/Release

I think you can use also move, I never tried. The error message tell you bson.js is missing in "../build/Release folder", so you only have to put the file in the right place

fedemengo
  • 626
  • 2
  • 7
  • 24