angular-cli: Cannot read property 'read' of undefined

System

Windows 10 - 64bit

Versions

angular-cli: 1.0.0-beta.15

npm: 3.10.7

node: 6.6.0

angular’s versions:@angular/common”: “2.0.1”, “@angular/compiler”: “2.0.1”, “@angular/core”: “2.0.1”, “@angular/forms”: “2.0.1”, “@angular/http”: “2.0.1”, “@angular/material”: “^2.0.0-alpha.9”, “@angular/platform-browser”: “2.0.1”, “@angular/platform-browser-dynamic”: “2.0.1”, “@angular/router”: “3.0.0”,

Repro steps.

I did change the defaults -> styleExt to “scss”, so the angular would create the scss files for me, but I did not try creating anything before the change. I also did an installation of @anuglar/material package. The app was completely new (state right after ‘ng new XXX’). Now I was trying to create the first component and it’s creating it, but after creating a .ts file it shows me the error above.

The log given by the failure.

C:\SERVER\htdocs\MySite>ng g component sidenav
  installing component
  identical src\app\sidenav\sidenav.component.css
  identical src\app\sidenav\sidenav.component.html
  identical src\app\sidenav\sidenav.component.spec.ts
  identical src\app\sidenav\sidenav.component.ts
  Cannot read property 'read' of undefined
  TypeError: Cannot read property 'read' of undefined
    at InsertChange.apply (C:\SERVER\htdocs\MySite\node_modules\@angular-cli\ast-tools\src\change.js:96:20)
    at C:\SERVER\htdocs\MySite\node_modules\@angular-cli\ast-tools\src\change.js:71:61
    at process._tickCallback (internal/process/next_tick.js:103:7)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 14
  • Comments: 16 (1 by maintainers)

Most upvoted comments

it seems it is fixed now in beta 16… I just added this answer in stackoverflow: http://stackoverflow.com/questions/39777519/angular2-error-while-creating-new-component-via-cli/39794397#39794397

Check the version and make sure you are on latest:

ng -v
angular-cli: 1.0.0-beta.16
node: 6.2.0
os: darwin x64

Remove old and install new:

npm uninstall -g angular-cli
npm remove cache
npm install -g angular-cli@latest

if you have an existing project: may also need to remove node_modules

IMPORTANT STEPS look everywhere for beta.15 and replace with beta.16

Change:

angular-cli.json:
"version": "1.0.0-beta.16",

package.json:
  "devDependencies": {
    "angular-cli": "1.0.0-beta.16",

Fixed in beta.16.

Well, it’s not a big problem, because the only problem is that it’s not adding the components, etc. to the app.module.ts, so I’m working with it and manually add them there.

But well, it would be great to have it all repaired again.