angular – Alias已被“–collection”选项使用,不能被“–change-detection”选项使用

前端之家收集整理的这篇文章主要介绍了angular – Alias已被“–collection”选项使用,不能被“–change-detection”选项使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
环境:

> Ubuntu 16.04
> Angular CLI 1.7.3

我通过执行生成组件仪表板来获取错误,但是也会发生ng generate c

$ng generate component dashboard
The "c" alias is already in use by the "--collection" option 
and cannot be used by the "--change-detection" option.
Please use a different alias.

我试图在npm中查找错误,蚂蚁我得到以下错误

$npm list
...
npm ERR! peer dep missing: @angular-devkit/core@0.4.5,required by @schematics/angular@0.4.5
npm ERR! peer dep missing: @angular-devkit/schematics@0.4.5,required by @schematics/angular@0.4.5

它看起来与npm validate别名有关

function angular-cli.command.prototype.validateAlias (option,alias)

但我不确定为什么选择“c”代替“组件”.

解决方法

我不知道这个错误的根本原因,但是这个 commit改变了很多别名(包括“c”代表“组件”)……
如果在node_modules/@schematics/angular/component/schema.json中将其本地更改为“cd”,则ng generate再次起作用.

请注意,在新项目中使用ng g组件测试时,我不会重现此错误.我在产生错误的项目中使用@nrwl / nx.问题可能在于版本不匹配……我不知道是什么.

猜你在找的Angularjs相关文章