我通过执行ng g c user
得到这个错误,但它也发生在ng generate component
,我不明白我需要一个帮助:
“ - ”选项已经使用了“ - ”选项,“ - change-detection”选项不能使用它。请使用其他别名。
我不知道为什么要改变但是有一个新的commit到包重命名一些别名并在你的项目中产生这个bug寻找文件
node_modules/@schematics/angular/component/schema.json
在这看看ChangeDetection类别并将别名属性从c更改为cd,例如再试一次。
"changeDetection": {
"description": "Specifies the change detection strategy.",
"enum": ["Default", "OnPush"],
"type": "string",
"default": "Default",
"alias": "cd"
},
有了这个,我就能够再次运行ng g c Home或ng generate component Home。
希望这可以帮助。
按照答案的建议更改schema.json对我来说不起作用。我正在使用全球安装的角度cli @ 1.7.4。由于这个问题似乎是由@ schematics / angular(在我的情况下为v0.7.5)引起的,我从我的项目依赖项中卸载了这个包
npm uninstall @schematics/angular --save
之后,ng generate component
为我工作。