我遇到了一些问题:npm update -g
我突然无法使用npm(在此提出问题:https://github.com/npm/npm/issues/12135)。
我尝试时会得到以下内容:
$ npm
-bash: npm: command not found
我尝试重新启动并运行,但我无法通过命令行安装它。我尝试使用在线列出的cURL命令并获得以下内容:
$ curl https://npmjs.org/install.sh | sudo sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 193 100 193 0 0 422 0 --:--:-- --:--:-- --:--:-- 422
sh: line 1: html: No such file or directory
sh: line 2: syntax error near unexpected token `<'
'h: line 2: `<head><title>301 Moved Permanently</title></head>
当我将sudo
移到线的前面时,我得到了以下内容:
sudo curl -L https://www.npmjs.com/install.sh | sh
[some successes here]
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/cli.js" "install" "-gf"
npm ERR! node v4.2.1
npm ERR! npm v3.8.5
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules' -> '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/.builtin-modules.DELETE'
npm ERR! at moveAway (/private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/lib/install/action/finalize.js:38:5)
npm ERR! at destStatted (/private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/lib/install/action/finalize.js:27:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules' -> '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/.builtin-modules.DELETE'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules' -> '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/.builtin-modules.DELETE'] parent: 'is-builtin-module' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/npm-debug.log
npm ERR! code 1
It failed
我检查过,~/.npm
文件夹仍然存在,并且有其内容,/usr/local/lib/node_modules/
也是如此。这里发生了什么?我该如何解决这个问题?