我正在使用 ubuntu 服务器 14.04.1 LTS,我相信它是一台 x32 机器
当尝试运行我的 Nodejs 实例时,出现错误
{ [错误:找不到模块 '../build/Release/bson'] 代码:'MODULE_NOT_FOUND' }
js-bson:无法加载c++ bson扩展,使用纯JS版本
请不要在此处链接与上述问题相关的答案。问题不在于加载失败。 它只是没有安装。这是我的 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
我尝试使用 node-gyp 和 -g 进行安装,但没有任何效果。 这已经到了我超越绝望的地步了。 有人可以帮我吗?非常感谢...
最佳答案
在依赖项中,删除 mongodb。 mongoose 将在其中安装驱动程序。
"dependencies": {
"express": "*",
"socket.io": "*",
"mongoose": "*"
}
然后做
sudo npm unistall mongodb
sudo npm cache clean
sudo npm install
如果问题仍然存在,则执行
sudo apt-get install build-essential
此外,如果您不是 root 用户,请始终在 sudo 下运行命令。
关于node.js - NPM install 未安装所有组件,node-gyp 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29460762/