我在nettutsplus上关注了一个教程,在运行npm update -g npm之后,当我键入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
答案 0 :(得分:17)
请参阅FAQ
如何更新npm?
npm update npm -g
npm update npm -g你也可以全部更新 通过在没有任何参数的情况下进行npm更新来过时的本地软件包,或者 通过执行npm update -g。
进行全局打包偶尔,npm的版本会进展到当前版本 版本无法与您拥有的版本一起正确安装 已安装。 (考虑一下,如果更新中存在任何错误 命令。)
在这些情况下,您可以这样做:
curl https://npmjs.org/install.sh | SH
<强>更新强>
安装脚本位置已经移动,所以请尝试:
curl -L https://npmjs.org/install.sh | SH