Environment:
I'm getting the error by executing ng generate component dashboard, but it also happens with 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.
I tried to look for an error in npm, ant I got the following error
$npm list
...
npm ERR! peer dep missing: @angular-devkit/[email protected], required by @schematics/[email protected]
npm ERR! peer dep missing: @angular-devkit/[email protected], required by @schematics/[email protected]
It looks something related with npm validate alias
function angular-cli.command.prototype.validateAlias (option, alias)
but I'm not sure why is taking "c" instead of "component".
I don't know the root cause of this error, but this commit changed a lot of aliases (including "c" for "component")...
If you change it locally in node_modules/@schematics/angular/component/schema.json
to "cd", ng generate
works again.
Note that when using ng g component test
in a new project I don't reproduce this error. I'm using @nrwl/nx in the project that produces errors. The problem might lie in a version mismatch between ... I don't know what.
I also dont know the cause of this error, but removing the explicitly installed @schematics/angular
package solved it somehow:
npm uninstall @schematics/angular --save-dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With