Reputation: 367
When i tried to run this command:
ng generate component <component-name>
I got this error:
Error: Cannot read property 'dasherize' of undefined
Cannot read property 'dasherize' of undefined
My angular config:
Angular CLI: 1.7.1
Node: 7.5.0
OS: darwin x64
Angular: 5.2.6
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cdk: 5.2.2
@angular/cli: 1.7.1
@angular/material: 5.2.2
@angular-devkit/build-optimizer: 0.4.2
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.10.1
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.6.2
webpack: 3.11.0
I've tried to remove node_modules, npm cache clean, node install and none of that worked.
Upvotes: 3
Views: 2618
Reputation: 21545
Uninstalled the existing packages @angular-devkit/core
and @angular-devkit/schematics
and installed the latest helped me
npm uninstall @angular-devkit/core
npm uninstall @angular-devkit/schematics
then install the latest
npm install @angular-devkit/core --save-dev
npm install @angular-devkit/schematics --save-dev
Upvotes: 2
Reputation: 44881
If you simply need to use the @Angular/Cli
in your project without the extended features provided by all the libraries of Angular DevKit (described here).
In your package.json
you can simply set inside your devDependencies
"@angular-devkit/core":"0.4.6"
ignoring other libraries like schematics
and package-update
which you can remove entirely.
In this way, you can use shortcuts aliases without problems like this one to create new components
ng g c my-new-component
Tested with "@angular/cli": "1.7.3"
Upvotes: 8
Reputation: 11
Helpful code snippet :
"@angular-devkit/core": "^0.6.8",
"@angular-devkit/schematics": "^0.6.8",
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.1.1",
Upvotes: 1
Reputation: 237
I had the same issue. I updated the package @angular-devkit/schematics
to the latest one and it started working.
Hope this will resolve your issue as well.
Upvotes: 1