我有最新的Node版本,根据https://www.npmjs.com/package/npm NPM附带最新版本
$ - node -v
v0.12.0
我试着看看安装了哪个版本的NPM
$ - npm -v
-bash: /usr/local/bin/npm: No such file or directory
当通过终端安装NPM时,上面的链接表明我收到以下错误
$ - curl -L https://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 172 0 0:00:01 0:00:01 --:--:-- 172
100 6239 100 6239 0 0 2797 0 0:00:02 0:00:02 --:--:-- 7636
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.7.0.tgz
unbuild npm@2.5.1
npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/4b/qrlv75j55nxd4_k63vv964n40000gn/T/npm.3664/package/cli.js" "rm" "npm" "-gf"
npm ERR! node v0.12.0
npm ERR! npm v2.7.0
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! errno: -13,
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! Please include the following file with any support request:
npm ERR! /private/var/folders/4b/qrlv75j55nxd4_k63vv964n40000gn/T/npm.3664/package/npm-debug.log
> npm@2.7.0 prepublish /private/var/folders/4b/qrlv75j55nxd4_k63vv964n40000gn/T/npm.3664/package
> node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test/*/*/node_modules && make -j8 doc
make: Nothing to be done for `doc'.
npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/4b/qrlv75j55nxd4_k63vv964n40000gn/T/npm.3664/package/cli.js" "install" "-gf"
npm ERR! node v0.12.0
npm ERR! npm v2.7.0
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! errno: -13,
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! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/npm' }
npm ERR! Please include the following file with any support request:
npm ERR! /private/var/folders/4b/qrlv75j55nxd4_k63vv964n40000gn/T/npm.3664/package/npm-debug.log
It failed
运行sudo curl -L https://npmjs.org/install.sh | sh
答案 0 :(得分:0)
好吧,您的错误看起来像是由于访问事项(如果您读取错误),因此请检查列出的文件路径上的权限。
你的第一个问题可能类似;我尝试找到npm可执行文件,并在尝试再次安装之前查看有哪些权限。
答案 1 :(得分:0)
我能够解决它。在我的根目录cd ~
上,我输入sudo chown -R $USER /usr/local
,然后使用sudo再次运行curl命令。
答案 2 :(得分:0)
在NPM的网站上有一个很棒的视频,根据您的需要为您提供一些如何解决这个问题的方法。为我工作。
https://docs.npmjs.com/getting-started/fixing-npm-permissions