无法加载c ++ bson扩展

无法加载c ++ bson扩展

这里有一个总节点noob。我一直在尝试设置一个示例节点应用程序但每次尝试运行时都会弹出以下错误:

节点应用

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

events.js:72
        throw er; // Unhandled 'error' event
              ^Error: failed to connect to [#$%67890 :27017]
    at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:830:16
    at process._tickCallback (node.js:415:13)


烙印99
浏览 630回答 3
3回答

不负相思意

通过添加此行尝试捕获块路径,轻松解决问题:&nbsp;node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.jsbson&nbsp;=&nbsp;require('bson');&nbsp;&nbsp;instead&nbsp; bson&nbsp;=&nbsp;require('./win32/ia32/bson');bson&nbsp;=&nbsp;require('../build/Release/bson');就这些!!!

守候你守候我

在WIN 8.1上好像我在package.json文件中使用了错误版本的mongoose。我从package.json中删除了行“mongoose”:“^ 3.8.15”CLI:npm install mongoose --save现在它在package.json中说“mongoose”:“^ 4.0.6”,我的错误消失了。

万千封印

Followint @ user1548357我决定更改模块文件本身。为了避免下面有效评论指出的问题,我在postinstall脚本中包含了我的更改,以便我可以设置并忘记它,并确保它将在我的模块安装时运行。//&nbsp;package.json"scripts":&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;other&nbsp;scripts &nbsp;&nbsp;&nbsp;&nbsp;"postinstall":&nbsp;"node&nbsp;./bson.fix.js"},并且脚本是://&nbsp;bson.fix.jsvar&nbsp;fs&nbsp;=&nbsp;require('fs');var&nbsp;file&nbsp;=&nbsp;'./node_modules/bson/ext/index.js'fs.readFile(file,&nbsp;'utf8',&nbsp;function&nbsp;(err,data)&nbsp;{ &nbsp;&nbsp;if&nbsp;(err)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;console.log(err); &nbsp;&nbsp;} &nbsp;&nbsp;var&nbsp;result&nbsp;=&nbsp;data.replace(/\.\.\/build\/Release\/bson/g,&nbsp;'bson'); &nbsp;&nbsp;fs.writeFile(file,&nbsp;result,&nbsp;'utf8',&nbsp;function&nbsp;(err)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(err)&nbsp;return&nbsp;console.log(err); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log('Fixed&nbsp;bson&nbsp;module&nbsp;so&nbsp;as&nbsp;to&nbsp;use&nbsp;JS&nbsp;version'); &nbsp;&nbsp;});});
打开App,查看更多内容
随时随地看视频慕课网APP