Javascript ,我通过安装mongodb和mongodb服务器解决了这个问题 yum install mongodb mongodb-server

Javascript ,我通过安装mongodb和mongodb服务器解决了这个问题 yum install mongodb mongodb-server,javascript,node.js,express,mongoose,dependencies,Javascript,Node.js,Express,Mongoose,Dependencies,我认为这不是生产最小容器的最佳方法。但我可以将范围限制在以下包中 ============================================================================================================== Package Arch Version Repository S

我认为这不是生产最小容器的最佳方法。但我可以将范围限制在以下包中

==============================================================================================================
 Package                          Arch              Version                          Repository          Size

==============================================================================================================
Installing:
 mongodb                          x86_64            2.6.5-2.el7                      epel                57 M
 mongodb-server                   x86_64            2.6.5-2.el7                      epel               8.7 M
Installing for dependencies:
 boost-filesystem                 x86_64            1.53.0-18.el7                    base                66 k
 boost-program-options            x86_64            1.53.0-18.el7                    base               154 k
 boost-system                     x86_64            1.53.0-18.el7                    base                38 k
 boost-thread                     x86_64            1.53.0-18.el7                    base                56 k
 gperftools-libs                  x86_64            2.1-1.el7                        epel               267 k
 libpcap                          x86_64            14:1.5.3-3.el7_0.1               updates            137 k
 libunwind                        x86_64            1.1-3.el7                        epel                61 k
 snappy                           x86_64            1.1.0-3.el7                      base                40 k
我只是跑:

sudo npm install bson


而且一切都正常。

对于Windows 7.1,以下指导帮助我修复构建环境:


我可以通过卸载和重新安装monk软件包来解决这个问题。
初始安装似乎有一个损坏的mongodb/bson依赖项。

不幸的是,以上所有答案都只对了一半。。 花了很长时间才弄明白

Mongoose bson安装通过npm抛出警告并导致错误

npm install -g node-gyp

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

这就像魔术一样

我也遇到了同样的问题,尝试了这么多选项,但在上次的
npm intall
中,我的mean app文件夹起了作用。

我遇到了这个问题,因为我在Git存储库中包含了node_modules文件夹。当我在另一个系统上重建node_模块时,它工作了。其中一个运行Linux,另一个运行OS X。也许他们也有不同的处理器体系结构。

在Windows 7(x64)上唯一对我有帮助的是:

使用x32版本重新安装node和python。
我花了很多时间处理这个错误:

加载C++ +BSON扩展< /P>失败 最后,当我安装module

node gyp
(用于构建本机插件)甚至使用visual studio安装windows SDK时,nodejs没有将组装好的模块
bson.node
识别为一个模块。重新安装后,问题消失了

再说一遍,这个错误意味着什么

事实上,这甚至不是错误。你仍然可以使用猫鼬。但是在这种情况下,您得到的不是
bson
模块的快速本机实现,而是
js实现
,速度较慢


我看到了许多提示,如:“编辑节点模块内部的路径深度…”-这是完全无用的,因为它不能解决问题,只是关闭了错误消息。

我在CentOS上通过

  • sudo yum group安装“开发工具”
  • sudo npm安装-g节点gyp
  • rm-r节点_模块
  • npm缓存清理
  • npm安装

    • 只是想说我也有错误

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

      但没有其他错误。我尝试了所有方法,结果发现我在package.json文件中指定的mongodb驱动程序与我的mongodb版本不兼容。我把它改成了我的最新版本(1.4.34),它成功了

      sudo npm rebuild
      为我修复了它。

      在WIN 8.1上

      似乎我在
      package.json
      文件中使用了错误版本的mongoose

      我从
      package.json
      中删除了行
      “mongoose”:“^3.8.15”

       "dependencies": {
          "consolidate": "~0.9.1",
          "express": "3.x",
          "mongodb": "~2.0.36",
          "mongoose": "^4.1.12"
        }
      
      CLI:

      bson = require('../build/Release/bson');
      
      bson = require('bson');
      
      npm install mongoose --save
      

      现在它在
      package.json中显示了
      “mongoose”:“^4.0.6”
      ,我所犯的错误消失了。

      我最终通过在
      package.json
      中将我的mongodb依赖项版本更新为~2.0.36,纠正了这个错误

       "dependencies": {
          "consolidate": "~0.9.1",
          "express": "3.x",
          "mongodb": "~2.0.36",
          "mongoose": "^4.1.12"
        }
      

      Followint@user1548357我决定更改模块文件本身。为了避免下面的有效评论指出的问题,我在安装后脚本中包含了我的更改,这样我就可以设置并忘记它,并确保在安装模块时它将运行

      // package.json
      "scripts": {
          // other scripts
          "postinstall": "node ./bson.fix.js"
      },
      
      剧本是:

      // bson.fix.js
      var fs = require('fs');
      var file = './node_modules/bson/ext/index.js'
      fs.readFile(file, 'utf8', function (err,data) {
        if (err) {
          return console.log(err);
        }
        var result = data.replace(/\.\.\/build\/Release\/bson/g, 'bson');
        fs.writeFile(file, result, 'utf8', function (err) {
           if (err) return console.log(err);
           console.log('Fixed bson module so as to use JS version');
        });
      });
      

      只需添加这条线,就可以轻松解决问题 路径:
      node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.js

      bson = require('bson');  instead 
      
      bson = require('./win32/ia32/bson');
      bson = require('../build/Release/bson'); 
      

      就这些

      错误是
      无法连接到
      ,因此我认为
      bson
      消息可能与此无关,实际上并不重要。你确定你的Mongo连接设置正确吗?有趣的故事我只在windows机器上得到这个错误。。。我还没有尝试安装node gyp,但我几乎尝试了所有其他方法,但仍然出现错误。而巧克力的安装基本上不是JS BSON代码,现在的速度和C++差不多吗?如果是这样的话,这真的是一个问题吗?对于使用较新IOJ的人来说,遇到这个问题,我已经打开了跟踪这个问题的记录单:注意:我使用Keystone.js作为我的mvc框架。对我来说,您可以将“./build/Release/bson”更改为“./browser\u build/bson”。如果你向上看,你会看到browser\u build文件夹。这是有用的信息。我发现我把mongodb用户帐户信息和数据库的实际mongodb用户信息弄混了。嗯,我遇到了同样的问题。不过,我的本地测试服务器上的一切都正常工作,我使用的是mongoHQ,因此不需要本地mongo实例,还有什么可能出错呢?忘了这一点,下面Pradeep的答案解决了:)+1。我所要做的就是最后3行——我想我的之所以没有建成,是因为它是
      mongoskin
      模块的一部分。哇!sudo-apt-get-install-gcc-make-build-essential是我见过的最好的Node.js+Ubuntu开发技巧之一。如果你习惯于开发web应用程序,并且只在Ubuntu上使用Node.js进行开发,那么它绝对会改变游戏规则。安装
      gcc
      make
      以及
      build-essential
      的原因是什么?后者取决于另外两个,因此无论如何都要安装()。做
      sudo-apt-get-install-build-essential
      就足够了。在windows上如何??我在Windows命令提示符C++:\用户\\Me\Dea\DoDePia\DATAGNE.JS{[错误:找不到模块'/Buff/Relp/BSON ']代码:'MexEnEnthfind find '}:加载C+BBSON扩展失败,使用纯JS版本{[错误:找不到模块'/Buff/Relp/BSON ']失败了。代码:“MexeNothByDebug”} JS BSN:加载C++ BSON扩展失败,使用纯JS版本正确连接到服务器窗口机器(对我来说也是如此),但我也输入了<代码> > <代码> >代码> > DeVele/NoDEYMys/BSON/<代码>。
      sudo npm update 
      
      npm install bson npm update
      npm config -g set python "/usr/bin/python2"
      
      rm -rf node_modules
      npm cache clean 
      npm install
      
      rm -rf node_modules
      npm cache clean
      npm install
      
      /node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.js 
      
      bson = require('../build/Release/bson');
      
      bson = require('bson');
      
      yum install mongodb mongodb-server
      
      ==============================================================================================================
       Package                          Arch              Version                          Repository          Size
      
      ==============================================================================================================
      Installing:
       mongodb                          x86_64            2.6.5-2.el7                      epel                57 M
       mongodb-server                   x86_64            2.6.5-2.el7                      epel               8.7 M
      Installing for dependencies:
       boost-filesystem                 x86_64            1.53.0-18.el7                    base                66 k
       boost-program-options            x86_64            1.53.0-18.el7                    base               154 k
       boost-system                     x86_64            1.53.0-18.el7                    base                38 k
       boost-thread                     x86_64            1.53.0-18.el7                    base                56 k
       gperftools-libs                  x86_64            2.1-1.el7                        epel               267 k
       libpcap                          x86_64            14:1.5.3-3.el7_0.1               updates            137 k
       libunwind                        x86_64            1.1-3.el7                        epel                61 k
       snappy                           x86_64            1.1.0-3.el7                      base                40 k
      
      sudo npm install bson
      
      sudo npm update
      
      npm install -g node-gyp
      
      git clone https://github.com/mongodb/js-bson.git
      cd js-bson
      npm install
      node-gyp rebuild
      
      Failed to load c++ bson extension, using pure JS version
      
      npm install mongoose --save
      
       "dependencies": {
          "consolidate": "~0.9.1",
          "express": "3.x",
          "mongodb": "~2.0.36",
          "mongoose": "^4.1.12"
        }
      
      // package.json
      "scripts": {
          // other scripts
          "postinstall": "node ./bson.fix.js"
      },
      
      // bson.fix.js
      var fs = require('fs');
      var file = './node_modules/bson/ext/index.js'
      fs.readFile(file, 'utf8', function (err,data) {
        if (err) {
          return console.log(err);
        }
        var result = data.replace(/\.\.\/build\/Release\/bson/g, 'bson');
        fs.writeFile(file, result, 'utf8', function (err) {
           if (err) return console.log(err);
           console.log('Fixed bson module so as to use JS version');
        });
      });
      
      bson = require('bson');  instead 
      
      bson = require('./win32/ia32/bson');
      bson = require('../build/Release/bson');