npm 报错 gyp ERR! stack Error: EACCES, stat '/home/chen/.node-gyp/0.8.4'
发布于 12 年前 作者 jiyinyiyong 18465 次浏览 最后一次编辑是 8 年前

不止一次遇到 ~/.node-gyp 文件无法访问的问题, 没有搜到明确的答案, 我尝试过手动创建该文件然后修改权限, 也没有成功… 请问是怎么回事啊?

系统 12.04 , Node 和 npm 都是从 官方写的 PPA 安装的.

sudo npm install node.io -g
npm http GET http://registry.npmjs.vitecho.com/node.io
npm http 304 http://registry.npmjs.vitecho.com/node.io
npm http GET http://registry.npmjs.vitecho.com/htmlparser
npm http GET http://registry.npmjs.vitecho.com/coffee-script
npm http GET http://registry.npmjs.vitecho.com/jquery
......省略 .....
npm http 304 http://registry.npmjs.vitecho.com/cssom
npm http 304 http://registry.npmjs.vitecho.com/contextify
npm http GET http://registry.npmjs.vitecho.com/bindings
npm http 304 http://registry.npmjs.vitecho.com/bindings

> contextify[@0](/user/0).1.3 install /usr/lib/node_modules/node.io/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES, stat '/home/chen/.node-gyp/0.8.4'
gyp ERR! System Linux 3.2.0-26-generic-pae
gyp ERR! command "node" "/usr/lib/nodejs/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/node.io/node_modules/jsdom/node_modules/contextify
gyp ERR! node -v v0.8.4
gyp ERR! node-gyp -v v0.6.1
gyp ERR! not ok 
npm WARN optional dep failed, continuing contextify[@0](/user/0).1.3
/usr/bin/io -> /usr/lib/node_modules/node.io/bin/io
/usr/bin/node.io -> /usr/lib/node_modules/node.io/bin/node.io
/usr/bin/node.io-web -> /usr/lib/node_modules/node.io/bin/node.io-web
node.io[@0](/user/0).4.12 /usr/lib/node_modules/node.io
├── request[@2](/user/2).9.202
├── coffee-script[@1](/user/1).3.3
├── htmlparser[@1](/user/1).7.6
├── jquery[@1](/user/1).7.3 (navigator[@1](/user/1).0.1, location[@0](/user/0).0.1, xmlhttprequest[@1](/user/1).4.2)
└── jsdom[@0](/user/0).2.15 (cssom[@0](/user/0).2.5)

尝试升级 npm 出错, 想起 PPA 安装的路径和编译安装差别较大, 这会有问题吗?

sudo npm install -g npm
npm http GET http://registry.npmjs.vitecho.com/npm
npm http 200 http://registry.npmjs.vitecho.com/npm
npm http GET http://registry.npmjs.vitecho.com/npm/-/npm-1.1.45.tgz
npm http 200 http://registry.npmjs.vitecho.com/npm/-/npm-1.1.45.tgz
npm ERR! error rolling back Error: Refusing to delete: /usr/bin/npm not in /usr/lib/node_modules/npm
npm ERR! error rolling back     at clobberFail (/usr/lib/nodejs/npm/lib/utils/gently-rm.js:41:12)
npm ERR! error rolling back     at next (/usr/lib/nodejs/npm/lib/utils/gently-rm.js:27:14)
npm ERR! error rolling back     at /usr/lib/nodejs/npm/lib/utils/gently-rm.js:36:12
npm ERR! error rolling back     at Object.oncomplete (fs.js:297:15)
npm ERR! error rolling back  npm[@1](/user/1).1.45 { [Error: Refusing to delete: /usr/bin/npm not in /usr/lib/node_modules/npm] code: 'EEXIST', path: '/usr/bin/npm' }
npm ERR! Refusing to delete: /usr/bin/npm not in /usr/lib/node_modules/npm
File exists: /usr/bin/npm
Move it away, and try again. 

npm ERR! System Linux 3.2.0-26-generic-pae
npm ERR! command "nodejs" "/usr/bin/npm" "install" "-g" "npm"
npm ERR! cwd /home/chen/git/zhongli
npm ERR! node -v v0.8.4
npm ERR! npm -v 1.1.45
npm ERR! path /usr/bin/npm
npm ERR! code EEXIST
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/chen/git/zhongli/npm-debug.log
npm ERR! not ok code 0
6 回复

之前也碰到, 后面才发现是没装相应的东西.

https://github.com/TooTallNate/node-gyp/

You will also need to install:

On Unix:

  • python
  • make
  • A proper C/C++ compiler toolchain, like GCC

On Windows:

  • Python (v2.7.2 recommended, v3.x.x not yet supported)
  • Microsoft Visual C++ (Express version works well)
  • For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK

之前我是win平台, 安装sockie.ui报错. 不知道和你的案例是否一样, 希望有帮助. https://github.com/TooTallNate/node-gyp/issues/97

@atian25 win7 64bit 要Microsoft Visual C++(不能是express版) 和 Windows 7 64-bit SDK

python make gcc 这三个命令都已经安装了的, 还是不行.

@xieren58 嗯,我那问题已经close的了

@jiyinyiyong 在那个github发issue吧

回到顶部