2012-02-10 138 views
5

我正在用root权限执行此操作。但仍然遇到访问被拒绝的错误。linux上的npm安装错误(ubuntu)

[email protected]:~$ sudo curl http://npmjs.org/install.sh | sh 
[sudo] password for hrishikesh: 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
100 7881 100 7881 0  0 12574  0 --:--:-- --:--:-- --:--:-- 37174 
tar=/bin/tar 
version: 
tar (GNU tar) 1.25 
Copyright (C) 2010 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. 

Written by John Gilmore and Jay Fenlason. 
install [email protected] 
fetching: http://registry.npmjs.org/npm/-/npm-1.1.1.tgz 
0.6.10 
1.1.1 
cleanup prefix=/usr/local 

All clean! 

npm ERR! Error: EACCES, permission denied '/usr/local/bin/npm' 
npm ERR! 
npm ERR! Please try running this command again as root/Administrator. 
npm ERR! 
npm ERR! System Linux 2.6.38-13-generic 
npm ERR! command "/usr/local/bin/node" "/tmp/npm.2959/package/cli.js" "rm" "npm" "-gf" 
npm ERR! cwd /tmp/npm.2959/package 
npm ERR! node -v v0.6.10 
npm ERR! npm -v 1.1.1 
npm ERR! path /usr/local/bin/npm 
npm ERR! code EACCES 
npm ERR! message EACCES, permission denied '/usr/local/bin/npm' 
npm ERR! errno {} 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /tmp/npm.2959/package/npm-debug.log 
npm not ok 
npm ERR! error installing [email protected] 
npm ERR! error rolling back [email protected] Error: EACCES, permission denied '/usr/local/bin/npm' 

npm ERR! Error: EACCES, permission denied '/usr/local/bin/npm' 
npm ERR! 
npm ERR! Please try running this command again as root/Administrator. 
npm ERR! 
npm ERR! System Linux 2.6.38-13-generic 
npm ERR! command "/usr/local/bin/node" "/tmp/npm.2959/package/cli.js" "install" "-gf" 
npm ERR! cwd /tmp/npm.2959/package 
npm ERR! node -v v0.6.10 
npm ERR! npm -v 1.1.1 
npm ERR! path /usr/local/bin/npm 
npm ERR! code EACCES 
npm ERR! message EACCES, permission denied '/usr/local/bin/npm' 
npm ERR! errno {} 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /tmp/npm.2959/package/npm-debug.log 
npm not ok 
It failed 
[email protected]:~$ 

我该怎么办?

回答

16

尝试

curl https://npmjs.org/install.sh | sudo sh 

在NPM readme看看。您当前的命令以root身份获取(curl)该脚本。您想以root身份运行(sh)脚本。

+0

它工作。花式的东西是安装也说“它工作”! :) 非常感谢。 – riship89 2012-02-10 06:14:24

+2

很高兴能帮到@ hrishikeshp19 – 2012-02-10 06:17:46

+1

网址已更改为https。所以现在是curl http://npmjs.org/install.sh | sudo sh – Lango 2013-06-25 09:59:51