14

我在nettutsplus上学习了一个教程,在运行 npm update -g npm 之后,当我输入 which npm 时,我的 npm 不再存在。这是错误。出了什么问题,我该如何解决?

localhost:~ macgeekalex$ npm update -g npm
npm http GET https://registry.npmjs.org/npm
npm http 200 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/-/npm-1.3.1.tgz
npm http 200 https://registry.npmjs.org/npm/-/npm-1.3.1.tgz
npm http GET https://registry.npmjs.org/npm/1.3.1
npm http 200 https://registry.npmjs.org/npm/1.3.1
npm http GET https://registry.npmjs.org/npm/-/npm-1.3.1.tgz
npm http 200 https://registry.npmjs.org/npm/-/npm-1.3.1.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! error rolling back  npm@1.3.1 { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/npm' }
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR!  { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/npm' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "update" "-g" "npm"
npm ERR! cwd /Volumes/Prodigy RAIDER PRO/Users/macgeekalex
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.2.32
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Volumes/Prodigy RAIDER PRO/Users/macgeekalex/npm-debug.log
npm ERR! not ok code 0
4

1 回答 1

18

查看常见问题解答

如何更新 npm?

npm update npm -g

npm update npm -g 你也可以通过不带任何参数的 npm update 来更新所有过时的本地包,或者通过 npm update -g 来更新全局包。

有时,npm 的版本会进步,以至于当前版本无法与您已经安装的版本一起正确安装。(考虑一下,如果更新命令中有错误。)

在这些情况下,您可以这样做:

卷曲https://npmjs.org/install.sh | 嘘

更新

安装脚本位置已被移动,因此请尝试:

curl -L https://npmjs.org/install.sh | 嘘

于 2013-06-26T17:40:06.880 回答