js-bson: Failed to load c++ bson extension, using pure JS version

3,212 views
Skip to first unread message

Taras Dudar

unread,
Jan 13, 2015, 12:30:58 AM1/13/15
to democra...@googlegroups.com
I've seen this error message:

js-bson: Failed to load c++ bson extension, using pure JS version

on my local machine for about two weeks now but I was hoping it was a problem with my machine and that heroku is running fine. I've decided to check my heroku log and I see the same problem there as well.

I've already tried two different node versions: 0.10.28 and 0.11.14. Should I try any other versions or do something else?



Guido Vilariño

unread,
Jan 13, 2015, 1:18:24 AM1/13/15
to Taras Dudar, democra...@googlegroups.com
This is one of those bizarre errors that still elude me to the day. It's something to do with MongoDB, Node and Mongoose, I'm just not sure what it is about exactly. Supposedly there are some issues with some versions of deps under the npm registry which causes this.

First thing to try is re-installing node/npm and maybe bumping the version to a higher release. More on this can be found on this github discussion but I can't seem to find the true reason for this error.

For dev machines, npm install -g bson should do the trick, though it may be viewed as a nasty hack.

Any light on this is welcome.

--
You received this message because you are subscribed to the Google Groups "DemocracyOS/app" group.
To unsubscribe from this group and stop receiving emails from it, send an email to democracyos-a...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Taras Dudar

unread,
Jan 13, 2015, 10:18:05 PM1/13/15
to democra...@googlegroups.com, taras....@gmail.com
I've read in one of the forums that this might be related to the multiple versions of bson installed on the machine. And there was something about npm using development version of bson while the app trying to use production version or vice verse. I cannot find this forum anymore.

I did try to bump up the version of node/npm from 0.10.28 to 0.11.14 and it did reduced the number of errors from

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

js-bson: Failed to load c++ bson extension, using pure JS version

to just

js-bson: Failed to load c++ bson extension, using pure JS version

I've got a history of all my commands since I've installed ubuntu. I did a grep on install and here is what I see:

   71  heroku run npm install
  124  npm install
  128  sudo npm install boot -g
  132  sudo npm install boot
  148  npm install boot --save
  149  sudo npm install boot --save
  187  sudo apt-get install xfce4 xfce4-goodies tightvncserver
  202  npm install node-version-resolver
  208  npm install nvm
  209  nvm install 0.10.28
  254  sudo apt-get install build-essential
  256  sudo apt-get install build-essential libssl-dev
  264  sudo apt-get install curl
  274  nvm install 0.10.28
  298  sudo apt-get install build-essential
  299  npm install mongodb
  437  sudo apt-get install nodejs-legacy
  473  sudo npm install -g n
  490  nvm install v0.10.28
  622  sudo apt-get install gcc make build-essential
  639  npm install node-gyp -g
  640  sudo npm install node-gyp -g
  660  sudo npm install gcc g
  704  sudo apt-get install gcc make build-essential
  707  nvm install 0.11.14
  739  sudo apt-get install gcc make build-essential
  740  npm install -g node-gyp

I think my problems might have started after I did

  437  sudo apt-get install nodejs-legacy

I also did this way at the beginning which might or might not be relevant to this problem.

sudo ln -s /usr/local/lib/node_modules /lib/node_modules



Anyway, running
 npm install -g bson
did not fix the problem, but here is what I've noticed:

while running  npm install -g bson I see:
bs...@0.2.17 /home/taras/.nvm/v0.11.14/lib/node_modules/bson

while runnimg  "make" for domocracyOS I see:

> bs...@0.2.17 install /home/taras/app-development/node_modules/connect-mongo/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

> bs...@0.2.12 install /home/taras/app-development/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

So it looks like there are two different versions of bson, 0.2.17 and 0.2.12 getting installed in two different places for mogodb.

Maybe that's where the problem is coming from?








Guido Vilariño

unread,
Jan 13, 2015, 10:28:56 PM1/13/15
to Taras Dudar, democra...@googlegroups.com
Supposedly node-gyp has something to do with the BSON issue; that's the repo the github discussion I mentioned is on. Maybe bumping the connect-mongo version or mongoose does the trick.

Different versions of BSON shouldn't be the issue since they're installed as dependencies of some other npm modules.

Cristian Douce

unread,
Jan 13, 2015, 11:41:03 PM1/13/15
to Guido Vilariño, democra...@googlegroups.com, Taras Dudar

Im concerned on why would you need to run npm install inside the heroku machine.

DemocracyOS has a profile to do all setup for you there, and heroku automaticallu recognizes your application type when you git push heroku master.

Maybe you could share your deployment flow with detail, since it seems it differs from what it's detailed in github's wiki.

You should think of heroku apps and containers as somethibg that is volatile. You should not worry about getting in an running anything by yourself. With each git push heroku should boot a new container, install everything and switch the network all for you. That is, in the end, the hole purpose of Heroku's existance.

And that's why we choose it as a PaaS option and detailed how to install it.

Cristian Douce

unread,
Jan 13, 2015, 11:41:44 PM1/13/15
to Guido Vilariño, Taras Dudar, democra...@googlegroups.com

I meant Procfile in the second paragraph.

Taras Dudar

unread,
Jan 14, 2015, 12:35:49 AM1/14/15
to democra...@googlegroups.com, gvil...@gmail.com, taras....@gmail.com
Cristian,

I'm not sure. It was about two months ago at the beginning of my democracyOS journey. That was my 71st command I ever run on Ubuntu. I went through my history file and it was right after I finished my "Getting Started at Heroku" tutorial and was trying to figure out how to install democracyOS. That was right after I've added mandrill and mongohq to my heroku app. I've had all sorts of different error messages trying to install democracyOS and was researching Google on how to fix those errors. I probably found this command on Google somewhere.

It took me about a week or two after I ran this command before I was finally able to get a clean install of democracyOS on my local machine and about another week or two before I was able to upload my first deployment to heroku. So hopefully running

heroku run npm install

did not break anything on heroku. But if you think this might be the culprit for my issues just let me know. I might have to delete the app and reinstall it from scratch anyway to figure out my notifier problem.


Now I have a little better idea on how everything works and I think I'm doing the same steps as everyone else. Here is my script that I run to get the latest democracyOS and notifier on heroku:

cd
cd app
git pull --rebase upstream development
cd
rm -rf app-development-old
mv app-development app-development-old
cp -r app app-development
cd app-development
rm -rf .git
cp -r ./../app-development-old/.git .
cd
cd app-development/config
cp sample.json development.json
cp sample.json production.json
cd
cd app-development
cp ./../app-development-old/package.json .
make clean
make
git add .
git commit -am "update"
git push heroku master

cd
cd notifier
git pull --rebase upstream development
cd
rm -rf notifier-development-old
mv notifier-development notifier-development-old
cp -r notifier notifier-development
cd notifier-development
rm -rf .git
cp -r ./../notifier-development-old/.git .
make
git add .
git commit -am "update"
git push heroku master

Please let me know if there is something I need to do differently.

Taras Dudar

unread,
Jan 14, 2015, 12:44:02 AM1/14/15
to democra...@googlegroups.com, taras....@gmail.com
Thanks Guido,

That did it. I've updated the mongoose version to 3.8.21 inside package.json and I've got a clean local build. Here is what I see now:


> bs...@0.2.17 install /home/taras/app-development/node_modules/connect-mongo/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

> bs...@0.2.17 install /home/taras/app-development/node_modules/mongoose/node_modules/mongodb/node_modules/bson

> (node-gyp rebuild 2> builderror.log) || (exit 0)

Notice that the versions of bson are the same now, 0.2.17, and apparently that fixes the issue. One observation to pint out though. It takes A LOT longer to compile now. With the previous setting it was about 1-2 min and now at least 10 min, maybe even 15 min.

I'll try to upload it to heroku now and see it it fixes the issue there as well.


Taras Dudar

unread,
Jan 14, 2015, 12:52:13 AM1/14/15
to democra...@googlegroups.com, taras....@gmail.com
Guido,

By the way, forgot to mention. This is about your node-gyp comment. I've seen this solution on Google and as you see from my history file I've tried the following:


  622  sudo apt-get install gcc make build-essential
  639  npm install node-gyp -g
  640  sudo npm install node-gyp -g
  660  sudo npm install gcc g
  704  sudo apt-get install gcc make build-essential
  707  nvm install 0.11.14
  739  sudo apt-get install gcc make build-essential
  740  npm install -g node-gyp

none of that worked in this case. I guess bumping up mongoose version is probably the right solution. Just let me know if you want me to PR this into GitHub.

Taras Dudar

unread,
Jan 14, 2015, 1:09:15 AM1/14/15
to democra...@googlegroups.com, taras....@gmail.com
OK, uploaded to heroku and checked the log. It's clean as well.

Guido Vilariño

unread,
Jan 14, 2015, 1:14:55 AM1/14/15
to Taras Dudar, democra...@googlegroups.com
15 min build wtf for real?

On 13 January 2015 at 22:09, Taras Dudar <taras....@gmail.com> wrote:
OK, uploaded to heroku and checked the log. It's clean as well.

--

Taras Dudar

unread,
Jan 14, 2015, 1:27:46 AM1/14/15
to democra...@googlegroups.com, taras....@gmail.com

heroku build went fine, just usual 1 min or so. I'm not sure what has happened on my local machine. I just tried it again and it's back to normal, just a couple of min. Maybe it had to install something the first time.

Guido Vilariño

unread,
Jan 14, 2015, 12:07:41 PM1/14/15
to Taras Dudar, democra...@googlegroups.com
Probably a connection issue. Build does a lot of requests.

On 13 January 2015 at 22:27, Taras Dudar <taras....@gmail.com> wrote:

heroku build went fine, just usual 1 min or so. I'm not sure what has happened on my local machine. I just tried it again and it's back to normal, just a couple of min. Maybe it had to install something the first time.

--
Reply all
Reply to author
Forward
0 new messages