在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)

查看:72
本文介绍了在Mac OS X(El Capitan)上安装angular-cli时出现@ angular-cli / ast-tools错误无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac OS X(El Capitan)上运行 sudo npm install -g @ angular-cli @ latest 时出现以下错误

I get the following error when I run sudo npm install -g @angular-cli@latest on Mac OS X (El Capitan)

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"

以下是调试日志:

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"

看起来这是angular-cli安装中存在的问题 https://github.com/angular/angular-cli/issues/2187

It looks like this is an existing issue in the angular-cli installation https://github.com/angular/angular-cli/issues/2187

有人可以建议为什么会发生这种情况?

Could someone please suggest why this might be happening?

提前感谢您的帮助。

推荐答案

结果,对Npm的更新修复了Mac OS X(El Capitan)上的这个问题。

Turns out, an update to npm fixed this issue on 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

运行以下命令后,以下是npm和node的版本:

After running the following commands, following were the versions of npm and node:

npm:3.10.9

npm: 3.10.9

节点:v6.6.0

这篇关于在Mac OS X(El Capitan)上安装angular-cli时出现@ angular-cli / ast-tools错误无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆