angular - 别名已被 "--collection"选项使用,不能被 "--change-detection"选项使用

标签 angular npm alias

环境:

  • Ubuntu 16.04
  • Angular CLI 1.7.3

我在执行 ng generate component dashboard 时遇到错误,但在 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 alias 相关

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

但我不确定为什么使用“c”而不是“component”。

最佳答案

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

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

关于angular - 别名已被 "--collection"选项使用,不能被 "--change-detection"选项使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49277567/

相关文章:

Angular 5 HttpClient GET : SUCCESSFUL if in constructor FAILS when ngOnInit

reactjs - 如何使可选的对等依赖项真正可选

android:允许创建一个 Activity 别名,其 targetActivity 在 aar/sdk 中

python - 我可以在 Python 列表推导中为表达式取别名以防止它们被多次评估吗?

Angular - 智能表格不会填满

angular - 具有多个组件的延迟加载功能模块在 Angular 6 中不起作用

javascript - webpack+babel npm 不想启动

node.js - 为什么我们应该避免在 Ubuntu 上使用 apt-get 安装 Node.js?

alias - 在 tcsh 中扩展别名

SQLiteObject 在 ionic 3 中未定义