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

前端 未结 30 2162
予麋鹿
予麋鹿 2020-11-28 02:19

I am getting the below error:

{ [Error: Cannot find module \'../build/Release/bson\'] code: \'MODULE_NOT_FOUND\' } 
  js-bson: Failed to load c++ bson extens         


        
相关标签:
30条回答
  • 2020-11-28 02:51

    Tried npm install mongoose --msvs_version=2012, if you have multiple Visual installed, it worked for me

    0 讨论(0)
  • 2020-11-28 02:51

    First copy bson.js code from browser_build folder

    second create new file bson.js and paste code

    third save the new file near to in index.js.

    0 讨论(0)
  • 2020-11-28 02:51

    I'm working with OS Windows 8.1 and I had the same problem. The source of the problem was the version of Python. I found the origin problem review the file ...\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos\builderror.log.

    I installed the correct version of Python (2.7.9 for 64 bits) and it resolved my problem.

    Note: The installed version of python must be equal or greater than 2.7.5 and less than 3.0.0

    0 讨论(0)
  • 2020-11-28 02:52

    You should never change files in NODE_MODULES library folder.

    Those files are result of npm install command.

    Basicaly, I think for Windows users - right way is use VM. It's what I'm doing when I work from home.

    All you need:

    for CentOS: yum install gcc gcc-c++ make openssl-devel

    for Debian/Ubuntu: apt-get install build-essential

    and then npm install or, if you have already done it - npm update

    0 讨论(0)
  • 2020-11-28 02:52

    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. Setting the http_proxy and https_proxy environment variables solved it.

    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.

    0 讨论(0)
  • 2020-11-28 02:53

    Find in npm module mongodb:

    ..\node_modules\mongodb\node_modules\bson\ext\index.js

    Change path to js version in catch block:

    bson = require('../build/Release/bson');
    

    To:

    bson = require('../browser_build/bson');
    

    Or copy file in:

    ..\node_modules\bson\build\Release\bson

    From:

    ..\node_modules\bson\browser_build\bson

    0 讨论(0)
提交回复
热议问题