在terminal找不到npm错误-npm

请帮我清除这个错误

Apples-Mac-mini:bin apple$ curl -L http://npmjs.org/install.sh | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 193 100 193 0 0 244 0 --:--:-- --:--:-- --:--:-- 471 100 6711 100 6711 0 0 431 0 0:00:15 0:00:15 --:--:-- 5456 sh: line 20: npm-install-3294.sh: Permission denied sh: npm-install-3294.sh: No such file or directory rm: npm-install-3294.sh: No such file or directory 

curl -L http://npmjs.org/install.sh | sudo sh

注意前面的sudo 。 您收到的错误是由于安装程序试图将文件复制到系统文件夹,需要pipe理权限。

另外,您实际上并不需要安装NPM,因为它包含在最新的Node.js版本中。 要在MacOS上安装Node.js,请参考他们的官方网站 。

要修复它,使用sudo运行sh:

 $ curl http://npmjs.org/install.sh | sudo sh