Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xpepermint opened this issue Sep 7, 2014 · 117 comments
Closed

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

xpepermint opened this issue Sep 7, 2014 · 117 comments

Comments

@xpepermint
Copy link

I clicked on Fork, cloned the repo and I attached this module to my project. I get this error

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

nodejs v0.11.13, latest osx. It looks that the problem is with the mongodb module (works with bson 0.2.15).

@lazdmx
Copy link

lazdmx commented Sep 8, 2014

Same problem

@bazineta
Copy link

bazineta commented Sep 8, 2014

Same issue here; backing off to 3.8.15 resolves the issue on OSX under 0.11.13.

@vkarpov15
Copy link
Collaborator

Yeah I've noticed this too. Your code will still work, just you may have worse performance. I'll fix this for next version.

@vkarpov15 vkarpov15 added this to the 3.8.17 milestone Sep 8, 2014
@xpepermint
Copy link
Author

ok

@leohidalgo
Copy link

Same problem

@merqlove
Copy link

Same here. Will stay 3.8.15 till changes.

@jamlfy
Copy link

jamlfy commented Sep 17, 2014

Ok.... Same problem!

@vkarpov15 vkarpov15 modified the milestones: 3.8.18, 3.8.17 Sep 29, 2014
@vkarpov15 vkarpov15 modified the milestones: 3.8.19, 3.8.18 Oct 22, 2014
@rubenstolk
Copy link

Any update on this?

@vkarpov15 vkarpov15 assigned alabid and unassigned alabid Nov 7, 2014
@vkarpov15 vkarpov15 modified the milestones: 3.8.20, 3.8.19 Nov 7, 2014
@grandimk
Copy link

I had the same problem (mongoose 3.8.19 and node 0.10.33). I've just resolve it after noticing that npm install (and npm update) compile the Debug version of bson but index.js (placed in node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.js in my case) require the Release version. As you can see in this section of the code:

try {
    // Load the precompiled win32 binary
    if(process.platform == "win32" && process.arch == "x64") {
      bson = require('./win32/x64/bson');  
    } else if(process.platform == "win32" && process.arch == "ia32") {
      bson = require('./win32/ia32/bson');  
    } else {
      bson = require('../build/Release/bson');  
    }   
} catch(err) {
    // Attempt to load the release bson version
    try {
        bson = require('../build/Release/bson');
    } catch (err) {
        console.error("js-bson: Failed to load c++ bson extension, using pure JS version");
        bson = require('../lib/bson/bson');
    }
}

I went inside the build directory and simply compile bson with the following command

make BUILDTYPE=Release all

Somewhere in the repository it has been changed from Release to Debug, but I didn't search into it.

@vkarpov15
Copy link
Collaborator

@Gas3 what version of npm are you using and what platform are you running this on? This really shouldn't be happening in stable node 0.10.x.

Also, I've managed to repro this - looks like a clean npm install with npm 2.0.0 (the version that comes with node 0.11.14) and node 0.11.14 makes this work fine. That is, rm -rf node_modules && npm install. Can y'all check if this helps?

@grandimk
Copy link

npm 2.1.7 on Os X 10.9.5

@vkarpov15
Copy link
Collaborator

Can you try a clean npm install - kill off node_modules and then npm install? This really sounds like an issue of changing versions of node without rebuilding js-bson.

@vkarpov15 vkarpov15 modified the milestones: 3.8.21, 3.8.20 Nov 26, 2014
@vkarpov15 vkarpov15 removed this from the 3.8.21 milestone Dec 18, 2014
@brunowego
Copy link

+1

@vkarpov15
Copy link
Collaborator

@brunobatista try rm -rf on your node_modules and do a clean npm install.

@Tyvain
Copy link

Tyvain commented Jan 8, 2015

Same problem:
node version: v0.10.35
npm version: 2.1.18

@fsanzv
Copy link

fsanzv commented Jan 13, 2015

Same problem here:
OS: Arch Linux
Node version: v0.10.35
npm version: 2.1.18
Mongoose version: 3.8.21

Tried 'rm -rf node_modules; npm cache clean; npm install' with no luck.
Tried also with Mongoose version 3.8.15 with same results.

@Jokero
Copy link
Contributor

Jokero commented Jan 13, 2015

Same issue was on Ubuntu 14.04. My steps:

  1. Updated npm to 2.1.18 from 1.3
  2. npm cache clean
  3. rm -rf node_modules
  4. npm i
    It works!

But I see error on Windows 8.1. This "require" throws error:

bson = require('./win32/ia32/bson'); 
The specified procedure could not be found.
C:\Users\d.kiriliuk\Projects\vozovoz\node_modules\mongoose\node_modules\mongodb\node_modules\bson\ext\win32\ia32\bson.node

File bson.node exists

@jwerre
Copy link

jwerre commented Jan 20, 2016

I'm getting the same error with Node v4.2.4, Mongo v2.6.11, OSX 10.11.2

npm install mongoose@4.3.6
npm WARN peerDependencies The peer dependency kerberos@~0.0 included from mongodb-core will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.

> kerberos@0.0.18 install /Users/jw/Work/sp_app/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild) || (exit 0)

  CXX(target) Release/obj.target/kerberos/lib/kerberos.o
  CXX(target) Release/obj.target/kerberos/lib/worker.o
  CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
../lib/kerberosgss.c:509:13: warning: implicit declaration of function 'gss_acquire_cred_impersonate_name' is invalid in C99 [-Wimplicit-function-declaration]
        maj_stat = gss_acquire_cred_impersonate_name(&min_stat,
                   ^
1 warning generated.
  CC(target) Release/obj.target/kerberos/lib/base64.o
  CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
  SOLINK_MODULE(target) Release/kerberos.node
npm WARN unmet dependency /Users/jw/Work/sp_app/node_modules/latest/node_modules/npm requires request@'~2.67.0' but will load
npm WARN unmet dependency /Users/jw/Work/sp_app/node_modules/request,
npm WARN unmet dependency which is version 2.27.0
mongoose@4.3.6 node_modules/mongoose
├── ms@0.7.1
├── hooks-fixed@1.1.0
├── async@0.9.0
├── regexp-clone@0.0.1
├── mpromise@0.5.4
├── mpath@0.1.1
├── muri@1.0.0
├── sliced@0.0.5
├── kareem@1.0.1
├── bson@0.4.21
├── mquery@1.6.3 (debug@2.2.0, bluebird@2.9.26)
└── mongodb@2.1.4 (es6-promise@3.0.2, readable-stream@1.0.31, kerberos@0.0.18, mongodb-core@1.2.32)

When I run my app I get:

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

I wonder if this is an OSX issue because I don't have any problems on Linux. Could this have something to do with the gcc, the default Clang compiler installed by XCode.

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix

@tomwang1013
Copy link

@vkarpov15 is right, update mongoose to 4.4.5 fix this problem

@jwerre
Copy link

jwerre commented Feb 26, 2016

@vkarpov15, Am I correct in assuming this issue is caused by running newer version of Mongoose with older versions of MongoDB — version 2.X for instance?

@vkarpov15
Copy link
Collaborator

No, the mongodb version has nothing to do with it.

@nityanarayan44
Copy link

[FIXED]

I also had this problem


OS: Windows 10
node: v4.2.3
npm: 2.14.7


i just simply set the python path

npm config set python python2.7

and reinstall the mongoose

npm install mongoose


and it worked.

@lutaoact
Copy link

lutaoact commented Apr 7, 2016

@nityanarayan44 It worked for me

@lutaoact
Copy link

lutaoact commented Apr 7, 2016

@mgol
I use OSX 10.10.5, node 4.4.2, npm 2.15.0, keystone 0.3.17

I went to node_modules/keystone/package.json, and remove mongoose from dependencies, then

npm config set python python2.7
npm install mongoose

this worked for me:

@Joselarcu
Copy link

Also worked for me the @nityanarayan44 solution

@sunfeng90
Copy link

Same problem.My version is node 2.15, platform Centos

@mgol
Copy link

mgol commented May 2, 2016

There's no such version of Node as 2.15 so I think you mean io.js. And
io.js has been unsupported by upstream for a long time, upgrade to Node 4
or 6 ASAP.

Michał Gołębiowski

@sunfeng90
Copy link

sunfeng90 commented May 2, 2016

@arefm Thx,it worked for me about updating the version 3.8.23.What's more,solveing another problem: length is undefined and so on.

@mnpenner
Copy link

mnpenner commented May 2, 2016

@mgol He was talking about npm. The latest version of npm2 is 2.15.4.

@jwerre
Copy link

jwerre commented May 2, 2016

@mnpenner I believe its 3.8.8

@mnpenner
Copy link

mnpenner commented May 3, 2016

@jwerre I said npm2. Some of us are stuck on npm 2 because 3 has a whole host of different problems.

@sunfeng90
Copy link

@mgol Sorry, the npm version is 2.15, not the node.

@sunfeng90
Copy link

@mnpenner Yes,you are a smart man!

@theladyjaye
Copy link

When using with Keystone this is what worked for me to get past that error:

add the following to my package.json deps:

"mongoose": "~4.4.16",
"mongodb": "~2.1.18",
"keystone": "^0.3.19",

then

npm install

finally

rm -rf node_modules/keystone/node_modules/mongodb
rm -rf node_modules/keystone/node_modules/mongoose

Now I don't get the error.

@HughGrant
Copy link

HughGrant commented May 24, 2016

@aventurella I hit the same rock when I am trying keystone today, thanks for your solution.

but now we get some extraneous errors and some missing errors, is this ok?

@albe-rosado
Copy link

@tomwang1013 updating mongoose solved the problem, but somehow my app is not connecting to the DB.....

@theothermattm
Copy link

In our case, the reason that the c++ version bson was not found was because we were behind a corporate proxy and something in the BSON build process needs to reach out to fetch files. When we looked in node_modules/bson/builderror.log, we saw an error like this:

gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: connect ECONNREFUSED
gyp ERR! stack     at errnoException (net.js:904:11)
gyp ERR! stack     at Object.afterConnect [as oncomplete] (net.js:895:19)

Which suggested that the proxy might be the issue.

Sorry for reawakening comments on this, but I wanted to post this for anyone else that hits this in the future since this thread was very helpful in solving our issue.

@Yugloocamai
Copy link

@aventurella thanks for your fix, it worked! Makes me feel a little funny though.

@GST5555
Copy link

GST5555 commented Jul 6, 2018

I have this issue on Windows 10, can't run a "basic" example either... is supposed that the installation files should provide all the stuff to run something, or at least have the instructions to do so...
This is fucking annoying!!!!! :@

@lineus
Copy link
Collaborator

lineus commented Jul 6, 2018

@GST5555 if you would like to get some help in real time, please feel free to join us in either of these communities:
Gitter.im
Slack

@icoronadoarellano
Copy link

The solution of @lutaoact is for me the most indicated if you use Windows. I tried with it and it solves my issue.

@vkarpov15
Copy link
Collaborator

If you're running into this issue, you're using an extremely old version of Mongoose. Please upgrade to Mongoose >= 5 👍

@Automattic Automattic locked and limited conversation to collaborators Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests