NPM安装不安装所有组件,节点GYP
我使用Ubuntu的服务器14.04.1 LTS,我相信是一个X32机器NPM安装不安装所有组件,节点GYP
当试图运行我的实例的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": "*"
}
当我运行须藤NPM安装(NPM是在最新的版本)我得到以下几点:
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN engine [email protected]: wanted: {"node":">= 0.10.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
npm WARN engine [email protected]: wanted: {"node":">=0.6.19"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
(...)
npm WARN engine [email protected]: wanted: {"node":">=0.4.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
-
> [email protected] 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 [email protected]: wanted: {"node":">=0.4.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
(...)
npm WARN engine [email protected]: wanted: {"node":">= 0.6.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
> [email protected] 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 [email protected]: wanted: {"node":">=0.8.19"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
(...)
npm WARN engine tin[email protected]: wanted: {"node":">=0.4.0"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
> [email protected] 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 [email protected]: wanted: {"node":">=0.6.19"} (current: {"node":"0.13.0-pre","npm":"2.7.5"})
> [email protected] 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)
> [email protected] 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)
> [email protected] 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)
> [email protected] 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更新,什么都不做,总是重复相同的输出。 我试着做节点GYP重建,这里是输出:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | 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
我试图与节点GYP与-g安装,毫无效果。 这是越来越到绝望的地步。 任何人都可以帮助我吗?非常感谢...
在依赖关系中,删除mongodb。猫鼬会在里面安装驱动程序。
"dependencies": {
"express": "*",
"socket.io": "*",
"mongoose": "*"
}
然后做
sudo npm unistall mongodb
sudo npm cache clean
sudo npm install
如果问题仍然存在,然后做
sudo apt-get install build-essential
同时,始终运行在sudo下的命令,如果你不是根用户。
这个问题在我身上发生过几次。
直到现在,清除缓存NPM足够:
npm cache clean
npm i
不要使用
sudo
!它需要清除全球NPM箱缓存,不是本地的,并且也没有,如果你用NVM作为普通用户(本地和全局包)
尝试添加在你的依赖特定的稳定和兼容版本:
"dependencies": {
"express": "^4.13.3",
"mongodb": "^2.0.47",
"mongoose": "^4.2.3",
"socket.io": "^1.3.7"
}
如果您正在运行npm install
一个项目里面,你不应该也NPM为sudo
运行。如果您不这样做npm
应该将您的模块安装在node_modules
目录中的项目中,并且您将能够在每个项目中使用不同的版本。
您的'node-gyp rebuild'不能用于预发布版本。因此,要么获得最新的稳定版本(根据他们的站点是12.2),要么运行'node-gyp rebuild --nodedir/path/to/install/node/to',然后将其添加到您的路径中。另外,有一次你说你运行了'sudo npm install',但是进一步表示你会忽略'sudo'。确保你持续运行命令。 – Tony 2015-04-06 22:17:26