npm每次下载nodejs

NPM downloads nodejs each time

我用的是 fedora,所以我从 repos 安装了 nodejs 和 npm。

但是我需要安装要求更新版本的 npm 的 SailsJS,所以我做了一个 sudo npm install npm -g,但是之后安装每个包都需要很多时间并且在详细模式下我每次都能看到nodejs 被获取并编译(即使我的 fedora 已经安装了相同的版本)。一些输出:

npm verb linkBins utf-8-validate@1.1.0
npm verb linkMans utf-8-validate@1.1.0
npm verb rebuildBundles utf-8-validate@1.1.0
npm verb rebuildBundles [ 'bindings', 'nan' ]
npm info install utf-8-validate@1.1.0

> utf-8-validate@1.1.0 install /lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp verb cli [ 'node',
gyp verb cli   '/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild' ]
gyp info using node-gyp@2.0.2
gyp info using node@0.10.36 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /bin/python2
gyp verb check python version `python2 -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.10.36
gyp verb command install [ 'v0.10.36' ]
gyp verb install input version string "v0.10.36"
gyp verb install installing version: 0.10.36
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.36"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate/.node-gyp"
gyp verb command install [ 'v0.10.36' ]
gyp verb install input version string "v0.10.36"
gyp verb install installing version: 0.10.36
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 0.10.36
gyp verb ensuring nodedir is created /lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate/.node-gyp/0.10.36
gyp verb created nodedir /lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate/.node-gyp
gyp http GET https://nodejs.org/dist/v0.10.36/node-v0.10.36.tar.gz
gyp http 200 https://nodejs.org/dist/v0.10.36/node-v0.10.36.tar.gz
gyp verb extracted file from tarball deps/zlib/zlib.h
gyp verb extracted file from tarball deps/zlib/deflate.h
gyp verb extracted file from tarball deps/zlib/inflate.h
gyp verb extracted file from tarball deps/zlib/zutil.h
gyp verb extracted file from tarball deps/zlib/examples/gzlog.h
gyp verb extracted file from tarball deps/zlib/crc32.h
gyp verb extracted file from tarball deps/zlib/inffast.h
gyp verb extracted file from tarball deps/zlib/trees.h
gyp verb extracted file from tarball deps/zlib/gzguts.h

你的问题似乎有这里提出的解决方案:https://github.com/TooTallNate/node-gyp/issues/610
基本上你必须在 .node-gyp 目录中下载节点 v0.10.36。