通过brew安装后,npm坏了

时间:2017-12-15 23:00:52

标签: node.js cordova npm homebrew

所以我在我的mac(High Sierra)上安装node,npm和cordova + ionic,它给了我这个问题:

Julime-Air:~ julime$ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-9.3.0_1.high_sierra.bottle.tar.gz
Already downloaded: /Users/julime/Library/Caches/Homebrew/node-9.3.0_1.high_sierra.bottle.tar.gz
==> Pouring node-9.3.0_1.high_sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
  /usr/local/Cellar/node/9.3.0_1: 5,125 files, 49.6MB
Julime-Air:~ julime$ npm install npm@latest -g
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ npm@5.6.0
updated 1 package in 16.966s
Julime-Air:~ julime$ npm -v
5.6.0
Julime-Air:~ julime$ npm install -g cordova ionic
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm ERR! path /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/ansistyles
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/ansistyles' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/.ansistyles.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/julime/.npm/_logs/2017-12-15T22_50_54_958Z-debug.log

尝试重新安装但没有运气

编辑: 以sudo身份运行并没有帮助。

EDIT2: 通过mac安装程序安装节点也无济于事。

1 个答案:

答案 0 :(得分:1)

在删除该mac-installer-node时遇到一些问题,我认为这解决了我的问题:

sudo chown -R $USER /usr/local
brew doctor
brew link --overwrite node

如果您遇到同样的问题,请评论一下是否有帮助。