Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I tried to install mean.io stack on an arch linux mini computer (the cubox). So I install nodejs and mongodb packages.

I retrieve the stack with Git, made an npm install (it was ok) but then:

I get this error after typing 'grunt':

[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version

fs.js:439
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory '/projects/mean/bower_components/jquery/dist/jquery.min.map'
    at Object.fs.openSync (fs.js:439:18)
    at Object.fs.readFileSync (fs.js:290:15)
    at module.exports (/projects/mean/node_modules/meanio/lib/bootstrap.js:31:27)
    at /projects/mean/node_modules/meanio/lib/mean.js:20:27
    at Config.onPackageRead (/projects/mean/node_modules/meanio/lib/config.js:101:25)
    at Promise.<anonymous> (/projects/mean/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:95:17)
    at Promise.emit (/projects/mean/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/projects/mean/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at Object.cb (/projects/mean/node_modules/mongoose/lib/query.js:1146:30)
[nodemon] app crashed - waiting for file changes before starting...

node version: v0.10.35 npm version: 2.1.18 MongoDB shell version: 2.6.6

What can I do now?? Any Idea??

Addtional info: I have a warn during npm install:

npm WARN cannot run in wd [email protected] (node-gyp rebuild 2> builderror.log) || (exit 0) (wd=/projects/mean/node_modules/bson)

Here is builderror.log :

cat builderror.log 
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11
gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:38:25)
gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:41:29)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:52:16
gyp ERR! stack     at Object.oncomplete (fs.js:108:15)
gyp ERR! System Linux 3.14.27-1-ARCH
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /projects/mean/node_modules/bson
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 

I did installed python (pacman -S python). python -V -> Python 3.4.2

###### More info:

After spending many time on this, I find something. It seems that 'bower install' can't be launch as root. And when I launch 'npm install' it calls 'bower install' and fail.

I try launching 'npm install --allow-root', but it doesn't work either.

So I wanted to create a new user in archlinux, but I don't know what group I should add him too. (I did create one, with some random groups but npm failed with a permission error).

If someone can send me a command to create a user in the good groups so I can test if that solve the problem it would be perfect.

Here is the error I get when launching npm install with a new user belonging to the group 'users':

Error: EACCES, open '.bower-registry/bower.herokuapp.com/lookup/angular_d18b8'
Installing module: mean-admin:
rm: could not remove file (code EACCES): packages/contrib/mean-admin/.bowerrc
More info:

I reinstall all from the start without being root. Create a user in wheel group. Now I am stuck during npm install here:

[tyvain@alarm fast-annonces]$ npm install 
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No README data
\
> [email protected] postinstall /projects/fast-annonces
> node node_modules/meanio/node_modules/mean-cli/bin/mean-postinstall


module.js:340
    throw err;
          ^
Error: Cannot find module '/projects/fast-annonces/node_modules/meanio/node_modules/mean-cli/bin/mean-postinstall'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

npm ERR! Linux 3.14.27-1-ARCH
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v0.10.35
npm ERR! npm  v2.1.18
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `node node_modules/meanio/node_modules/mean-cli/bin/mean-postinstall`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'node node_modules/meanio/node_modules/mean-cli/bin/mean-postinstall'.
npm ERR! This is most likely a problem with the mean package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/meanio/node_modules/mean-cli/bin/mean-postinstall
npm ERR! You can get their info via:
npm ERR!     npm owner ls mean
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /projects/fast-annonces/npm-debug.log

This is a nightmare!! :)

like image 686
Tyvain Avatar asked Jan 08 '15 10:01

Tyvain


2 Answers

I guess you did not have the make tools available when you installed your mongodb library. I suggest you do
Mac:

xcode-select --install 

Ubuntu:

sudo apt-get install gcc make build-essential 

and run

rm -rf node_modules
npm cache clean
npm install

You need python 2 for it to compile. If your path to python is for python 3 then do this :

npm config -g set python "/usr/bin/python2"

The 'EACCES` error means the program did not have enough privileges to do what is trying to.

From what I read about groups here, you need to add the user to the group wheel. Use this command :

gpasswd -a [user] [group]

Follow the link for a detailed understanding of groups and users.

like image 99
bluefog Avatar answered Nov 09 '22 00:11

bluefog


Unfortunately, All the above answers are only half right.. Took a long time to figure this out..

Mongoose bson install via npm throws warning and causes the error...

npm install -g node-gyp

git clone https://github.com/mongodb/js-bson.git
cd js-bson
npm install
node-gyp rebuild

This works like magic!!

like image 33
Rama Prashanth Avatar answered Nov 09 '22 00:11

Rama Prashanth