admin管理员组

文章数量:1292751

When i tried to run this mand:

ng generate ponent <ponent-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, mon, piler, piler-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.

When i tried to run this mand:

ng generate ponent <ponent-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, mon, piler, piler-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.

Share Improve this question asked Feb 22, 2018 at 15:31 user3516604user3516604 3673 silver badges9 bronze badges 2
  • 1 github./angular/angular-cli/issues/9662 – R. Richards Commented Feb 22, 2018 at 15:34
  • 3 Thank you, I fixed it by updating; @ angular-devkit/core from "0.0.23" to "0.4.2" and @ angular-devkit/schematics from"0.0.42" to "0.4.2" – user3516604 Commented Feb 22, 2018 at 15:54
Add a ment  | 

4 Answers 4

Reset to default 8

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 ponents

ng g c my-new-ponent

Tested with "@angular/cli": "1.7.3"

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

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.

Helpful code snippet :

 "@angular-devkit/core": "^0.6.8",
 "@angular-devkit/schematics": "^0.6.8",
 "@angular/cli": "^1.7.4",
 "@angular/piler-cli": "^5.1.1",

本文标签: javascriptCannot read property 39dasherize39 of undefinedStack Overflow