angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Cannot read property 'read' of undefined

Open Flyrell opened this issue 10 years ago • 16 comments

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)

Flyrell avatar Sep 29 '16 15:09 Flyrell

same for me

scastaldi avatar Sep 29 '16 21:09 scastaldi

Same error but not using scss. I simply tried generating a component. I'm using beta 15 of angular-cli, node 5.12.0, and 2.0.0 of the angular framework components. Windows 7, and it was working earlier. No changes except OS security updates.

b4youleap avatar Sep 29 '16 23:09 b4youleap

Same issue here. Ubuntu 16.04, beta 15 of angular-cli

pradeepb6 avatar Sep 29 '16 23:09 pradeepb6

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.

Flyrell avatar Sep 30 '16 01:09 Flyrell

Same issue here. Mac OS X and no SCSS

andreapaiola avatar Sep 30 '16 09:09 andreapaiola

same mac os x 10.11.6 while generating component

node 6.7.0

"dependencies": { "@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/platform-browser": "2.0.1", "@angular/platform-browser-dynamic": "2.0.1", "@angular/router": "3.0.0", "bootstrap": "^4.0.0-alpha.4", "core-js": "^2.4.1", "font-awesome": "^4.6.3", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", "zone.js": "^0.6.23" }, "devDependencies": { "@types/jasmine": "^2.2.30", "angular-cli": "1.0.0-beta.15", "codelyzer": "~0.0.26", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "4.0.5", "ts-node": "1.2.1", "tslint": "3.13.0", "typescript": "2.0.3" }

stmarco avatar Sep 30 '16 14:09 stmarco

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",

scastaldi avatar Sep 30 '16 15:09 scastaldi

important to also change it to "angular-cli": "1.0.0-beta.16" in your package.json devDependencies,

after that and changing my typescript from 2.0.3 to 2.0.2 it works for me

stmarco avatar Sep 30 '16 16:09 stmarco

I am facing the same issue, however even after following the steps mentioned.

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

Its still using beta.15

ghost avatar Sep 30 '16 18:09 ghost

Okay, when I updated the package.json and then ran an "npm install" from the project directory, that solved the issue.

Thanks.

ghost avatar Sep 30 '16 18:09 ghost

I have a Windows 10 machine with the same npm, node, and cli versions as my Win 7 and no issues. Strange.

b4youleap avatar Oct 01 '16 01:10 b4youleap

Works for me

andreapaiola avatar Oct 03 '16 07:10 andreapaiola

This issue should be closed I have reproduced it with the beta.15, but it's gone with beta.16 Thanks, @scastaldi

taras-budzyn avatar Oct 05 '16 20:10 taras-budzyn

Updated from "beta.15" to "beta.16" and problem disappeared.

skryvets avatar Oct 07 '16 13:10 skryvets

Fixed in beta.16.

filipesilva avatar Oct 10 '16 01:10 filipesilva

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.