我遇到了安装Node.js包管理器“npm”的问题。
在网站上,它提示您执行以下一行安装...
在网站上,它提示您执行以下一行安装...
curl http://npmjs.org/install.sh | sh
这会输出以下安装错误...
$ curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7184 100 7184 0 0 27012 0 --:--:-- --:--:-- --:--:-- 39256
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz
0.4.11
1.0.106
cleanup prefix=/usr
All clean!
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/cli.js" "rm" "npm" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/npm-debug.log
npm not ok
npm ERR! error installing npm@1.0.106 Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! error rolling back npm@1.0.106 Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/npm-debug.log
npm not ok
在谷歌搜索后,发现这是一个普遍的问题,解决方法是在相同命令前加sudo。
奇怪的是,在我的情况下似乎不起作用。如果我使用sudo运行相同的命令,就会出现以下情况。
$ sudo curl http://npmjs.org/install.sh | sh
Password:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7184 100 7184 0 0 9974 0 --:--:-- --:--:-- --:--:-- 40359
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz
0.4.11
1.0.106
cleanup prefix=/usr
All clean!
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/cli.js" "rm" "npm" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/npm-debug.log
npm not ok
npm ERR! error installing npm@1.0.106 Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! error rolling back npm@1.0.106 Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/npm-debug.log
npm not ok
It failed
我在这里一片空白。有什么想法吗?