【发布时间】:2015-11-02 04:07:27
【问题描述】:
我使用的是 ubuntu server 14.04.1 LTS,我认为它是 x32 机器
尝试运行我的 nodejs 实例时出现错误
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
请不要在此处链接与上述问题相关的答案。问题不在于加载失败。 只是没有安装。这是我的 package.json 依赖项:
"dependencies": {
"express": "*",
"socket.io": "*",
"mongodb": "*",
"mongoose": "*"
}
当我运行 sudo npm install(npm 是最新版本)时,我得到以下信息:
npm WARN package.json forum@0.0.1 No description
npm WARN package.json forum@0.0.1 No repository field.
npm WARN package.json forum@0.0.1 No README data
npm WARN engine express@4.12.3: wanted: {"node":">= 0.10.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
npm WARN engine mongoose@4.0.1: wanted: {"node":">=0.6.19"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
(...)
npm WARN engine options@0.0.6: wanted: {"node":">=0.4.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
-
> ws@0.5.0 install /usr/share/nginx/www/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
npm WARN engine hooks-fixed@1.0.1: wanted: {"node":">=0.4.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
(...)
npm WARN engine base64-arraybuffer@0.1.2: wanted: {"node":">= 0.6.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
> kerberos@0.0.10 install /usr/share/nginx/www/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
npm WARN engine bson-ext@0.1.0: wanted: {"node":">=0.8.19"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
(...)
npm WARN engine tinycolor@0.0.1: wanted: {"node":">=0.4.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
> ws@0.4.31 install /usr/share/nginx/www/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
npm WARN engine bson@0.2.21: wanted: {"node":">=0.6.19"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
> bson-ext@0.1.0 install /usr/share/nginx/www/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext
> (node-gyp rebuild 2> builderror.log) || (exit 0)
> kerberos@0.0.10 install /usr/share/nginx/www/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
> bson@0.2.21 install /usr/share/nginx/www/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
> bson@0.3.1 install /usr/share/nginx/www/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
事实上,在 node_modules 子文件夹中找不到这些文件夹(bson、kerberos、ws)。所以它真的是 MODULE_NOT_FOUND。
我尝试运行 npm update,什么也没做,总是重复相同的输出。 我尝试过 node-gyp 重建,输出如下:
gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.3
gyp info using node@0.13.0-pre | linux | ia32
gyp ERR! configure error
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack at install (/usr/local/lib/node_modules/node-gyp/lib/install.js:66:16)
gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/node-gyp/lib/configure.js:152:20)
gyp ERR! stack at /usr/local/lib/node_modules/node-gyp/lib/configure.js:95:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:723:7)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at maybeClose (child_process.js:1000:16)
gyp ERR! stack at Socket.<anonymous> (child_process.js:1168:11)
gyp ERR! stack at Socket.emit (events.js:107:17)
gyp ERR! stack at Pipe.close (net.js:461:12)
gyp ERR! System Linux 3.13.0-48-generic
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/share/nginx/www
gyp ERR! node -v v0.13.0-pre
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
我尝试使用带有 -g 的 node-gyp 进行安装,但没有任何效果。 这已经到了我超越绝望的地步。 任何人都可以帮助我吗?非常感谢...
【问题讨论】:
-
您的
node-gyp rebuild不适用于预发布版本。所以要么获取最新的稳定版本(根据他们的站点是 12.2),要么运行node-gyp rebuild --nodedir /path/to/install/node/to,然后将其添加到您的路径中。此外,有一次您说您运行了sudo npm install,但进一步赞扬您省略了sudo。确保您始终如一地运行命令。
标签: node.js mongodb ubuntu mongoose npm