gpt4 book ai didi

javascript - 使用monk访问Mongodb时使用纯JS版本,加载c++ bson扩展失败

转载 作者:行者123 更新时间:2023-12-02 16:45:38 24 4
gpt4 key购买 nike

当我想使用monk作为中间件访问mongodb时,提示

无法加载c++ bson扩展,使用纯JS版本

我正在运行的 evn 如下:

  1. OS X 优胜美地
  2. Node v0.10.32
  3. npm 1.4.28
  4. Mongodb 2.6.5
  5. 和尚0.9.1你们有人知道如何解决这个问题吗?

最佳答案

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

转到 Monk index.js 文件 (yourProjectDirectory/node_modules/monk/node_modules/mongodb/node_modules/bson/ext/index.js)

它应该看起来像

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.dir(err)
console.error("js-bson: Failed to load c++ bson extension, using pure JS version");
bson = require('../lib/bson/bson');
}
}

将 catch block 更改为

try {
...
} catch(err) {
// Attempt to load the release bson version
try {
bson = require('../browser_build/bson');
} catch (err) {
console.dir(err)
console.error("js-bson: Failed to load c++ bson extension, using pure JS version");
bson = require('../lib/bson/bson');
}
}

希望这有帮助

大卫

关于javascript - 使用monk访问Mongodb时使用纯JS版本,加载c++ bson扩展失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27140372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com