简体   繁体   English

在Mac OS X(El Capitan)上安装angular-cli时,无效的@ angular-cli / ast-tools错误

[英]Invalid @angular-cli/ast-tools error while installing angular-cli on Mac OS X (El Capitan)

I get the following error when I run sudo npm install -g @angular-cli@latest on Mac OS X (El Capitan) 在Mac OS X(El Capitan)上运行sudo npm install -g @angular-cli@latest时,出现以下错误

Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "angular-cli@latest"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3

npm ERR! Invalid name: "@angular-cli/ast-tools"

Following are the debug logs: 以下是调试日志:

2911 verbose stack Error: Invalid name: "@angular-cli/ast-tools"
2911 verbose stack at ensureValidName (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:281:15)
2911 verbose stack at Object.fixNameField (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:196:5)
2911 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:29:38
2911 verbose stack at Array.forEach (native)
2911 verbose stack at normalize (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:28:15)
2911 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:349:5)
2911 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5)
2911 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:214:31
2911 verbose stack at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:17:25)
2911 verbose stack at Glob. (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/glob/glob.js:146:7)
2912 verbose cwd /Users/XXX
2913 error Darwin 15.4.0
2914 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "angular-cli@latest"
2915 error node v6.7.0
2916 error npm v3.10.3
2917 error Invalid name: "@angular-cli/ast-tools"

It looks like this is an existing issue in the angular-cli installation https://github.com/angular/angular-cli/issues/2187 看来这是angular-cli安装中的现有问题https://github.com/angular/angular-cli/issues/2187

Could someone please suggest why this might be happening? 有人可以建议为什么会这样吗?

Thanks in advance for your help. 在此先感谢您的帮助。

Turns out, an update to npm fixed this issue on Mac OS X (El Capitan). 事实证明,对npm的更新解决了Mac OS X(El Capitan)上的此问题。

Here's how I resolved this issue: 这是我解决此问题的方法:

  sudo npm update npm -g
  npm --v
  node -v
  npm uninstall -g angular-cli
  sudo npm uninstall -g angular-cli
  sudo npm cache clean
  sudo npm install -g angular-cli@latest

After running the following commands, following were the versions of npm and node: 运行以下命令后,以下是npm和node的版本:

npm: 3.10.9 npm:3.10.9

node: v6.6.0 节点:v6.6.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM