Keystone-classic: Failed to load c++ bson extension

Created on 28 Jan 2015  ·  23Comments  ·  Source: keystonejs/keystone-classic

tried following a yo generator install of keystone but getting this error

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

I only get the server running when I stop and restart the terminal - any thoughts on removing the error

Most helpful comment

Just upgraded to the master branch, the error is gone.

In package.json:

"keystone": "https://github.com/keystonejs/keystone.git",

Then

rm -rf node_modules
npm install

All 23 comments

@sononix, can you provide additional specifics:

  • OS (I ask because I've encountered this issue on OSX when command developer tools are no available)
  • Keystone version
  • Node.js version
  • Anything else you think might be relevant

OS 10.10.1
keystone 0.2.42

Developer tools are installed
Mongodb - v2.6.7
GNU Make 3.81
gcc version 4.9.2 (Homebrew gcc 4.9.2_1)

mongodb installed using brew - I think only way I could get it to work
node was using version v0.10.32 - updated to v0.10.36 using nvm for management

that about it that I can think of

I haven't been able to replicate your issue, so unfortunately I don't have a definitive solution for you. However, I have encountered this issue in the past on more than one occasion. One time was related to the lack of developer tools on OS X (clearly not your case). Another time it was caused by some dependencies not properly installed (probably due to install errors I didn't notice). Something you can try is to reinstall all the app's dependencies. I'm not sure if you've tried this already, but it worked for me (at least once) the past.

cd /path/to/your/app
npm cache clean
rm -rf node_modules
npm install

NOTE: You may need to use sudo to run the above commands.

I have this issue too.

OS: Window 8.1
MongoDB: 3.0.1
Keystone: 0.3.2
Nodejs: 0.12.0

When remove node_modules and install again. I have some alert:

npm ERR! git clone git://github.com/michaelficarra/cscodegen.git undefined
npm ERR! git clone git://github.com/michaelficarra/cscodegen.git undefined
npm WARN optional dep failed, continuing cscodegen@git://github.com/michaelficar

npm WARN `git config --get remote.origin.url` returned wrong result (git://githu
b.com/michaelficarra/cscodegen.git) undefined
npm WARN `git config --get remote.origin.url` returned wrong result (git://githu
b.com/michaelficarra/cscodegen.git) undefined
npm ERR! git clone git://github.com/michaelficarra/cscodegen.git undefined
npm ERR! git clone git://github.com/michaelficarra/cscodegen.git undefined
npm WARN optional dep failed, continuing cscodegen@git://github.com/michaelficar
ra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383
\

And this issue still happen.

I m having the same issue.

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

This is always there before server starts.

issue exists even after

cd /path/to/your/app
npm cache clean
rm -rf node_modules
npm install

And the OS is windows-7,8

I think because Window OS dont have js-bson then they run pure JS. It is not big problem, because everything is fine. After I publish the code to online server using CentOS, this Error will no longer.

OK.. Thanks for reply. But there is another window 7 on which the code runs fine without the warning..

I have the same issue both in Windows 7 and CentOS 7. This started happening in one of the 3.x versions as I had not seen it before. In CentOS 7 I get:

processing: /src/keystone.js

2015-04-24 00:29:57,526 INFO success: node entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-04-24 00:29:57,881 DEBG 'node' stdout output:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }

2015-04-24 00:29:57,881 DEBG 'node' stderr output:
js-bson: Failed to load c++ bson extension, using pure JS version

Now this CentOS is a VM running in a windows host; not sure if windows' still the culprit as @SLyHuy doesn't see it in his CentOS deployment.

This error originates from your MongoDB installation. This SO answer should help:
http://stackoverflow.com/a/22054632

I had the same problem, it was because of the python version, i had to specify the version:

npm cache clean
rm -rf node_modules
export PYTHON=python2.7
npm install --python=python2.7

Same problem here, the SO answer did not help

OSX 10.11.1
Mongo 3.0.7
Node 5.0.0

It seems that the error comes some keystone (sub?)dependencies relying on outdated libraries. I only got here so far and it is quite annoying as it works great on Ubuntu 14.04 with a similar setup

Same problem here
OSX 10.11.1
Mongo 3.0.7
Node 4.2.1

Same here

OSX 10.11.1
Mongo 3.0.7
Node 5.0.0

Just because it hasn't already been mentioned here - this is a warning, not an error. I've just been ignoring it.

And it happens on Ubuntu 14.04 LTS too

Just upgraded to the master branch, the error is gone.

In package.json:

"keystone": "https://github.com/keystonejs/keystone.git",

Then

rm -rf node_modules
npm install

As @snowkeeper alluded, for Node 4 at least, this error is entirely upstream. It originates in the bson package itself, which the mongodb package depends on, which mongoose depends on. The error was corrected right around [email protected].

@fridays's suggestion to use the unstable Keystone 0.4.x alpha branch from master eliminates the error as the mongoose dependency was updated, resulting in a bson 4 dependency.

If Keystone 0.3.x is to be maintained, the solution is to bump the mongoose dependency from ~3.8.35 to ^4.1.3. There are backwards incompatible changes between Mongoose 3 and 4 - so Keystone updates might have to be backported from 0.4.x, or applied separately if 0.4.x is largely incompatible.

All of that said, since a pure JS fallback is available for bson and this error does not impede execution, I can't imagine that this issue should take much priority!

closing as dupe #1752

Ainsss...

I think is not necessary ninja tricks for solving this problem.

After creating your keystone project, install npm-check-updates for all users:

user@debian:~/myproject/my-site$ sudo npm install -g npm-check-updates

Then update your site packages.json:

user@debian:~/myproject/my-site$ npm-check-updates -u

And finally update all packages:

user@debian:~/myproject/my-site$ npm install

One last thing. If you chose 'jade' during deployment of keystone, maybe you will need to install 'jade' explicitly:

user@debian:~/myproject/my-site$ npm install jade --save

@manuel-alcocer : thank you, this was the only solution i found that worked for running Keystone.

Cheers :+1:

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

Had an issue where it was working locally but giving above error on Heroku.
I have so far added a postInstall script:

"postinstall": "npm i keystonejs/keystone"

This works but slows down deployments.
What is the version of keystone to which I have to upgrade to avoid this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacqueslareau picture jacqueslareau  ·  5Comments

ttsirkia picture ttsirkia  ·  4Comments

rigalpatel001 picture rigalpatel001  ·  5Comments

molomby picture molomby  ·  5Comments

zhdan88vadim picture zhdan88vadim  ·  5Comments