angular-cli: Uncaught TypeError: Cannot read property 'apply' of undefined on new install

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Versions.

@angular/cli: 1.0.0 node: 6.9.5 os: darwin x64 @angular/common: 4.0.3 @angular/compiler: 4.0.3 @angular/core: 4.0.3 @angular/forms: 4.0.3 @angular/http: 4.0.3 @angular/platform-browser: 4.0.3 @angular/platform-browser-dynamic: 4.0.3 @angular/router: 4.0.3 @angular/cli: 1.0.0 @angular/compiler-cli: 4.0.3

Repro steps.

npm install -g @angular/cli ng new projectname cd projectname ng serve –> Browse to localhost:4200 in Chrome

The log given by the failure.

When you first open the browser you get the following message: Angular is running in the development mode. Call enableProdMode() to enable the production mode.

Then the error Uncaught TypeError: Cannot read property ‘apply’ of undefined at XMLHttpRequest.desc.get [as ontimeout] (zone.js:1265) at XHRLocalObject.AbstractXHRObject._cleanup (abstract-xhr.js:149) at XMLHttpRequest.xhr.onreadystatechange (abstract-xhr.js:125) at XMLHttpRequest.wrapFn (zone.js:1230) at ZoneDelegate.invokeTask (zone.js:398) at Zone.runTask (zone.js:165) at XMLHttpRequest.ZoneTask.invoke (zone.js:460)

Desired functionality.

Bug fix or the ability to work out why it’s not actually working, i’ve cleaned the NPM cache, reinstalled with -g and still get an error.

Mention any other details that might be useful.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 104
  • Comments: 103 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Downgraded to zone.js@0.8.5 and the problem disappeared.

I got the same error.

screenshot 2017-04-22 15 51 51

Downgraded to zone.js@0.8.5 and the problem disappeared.

Works for me on both Chrome (58.0.3029.81) and Firefox (53.0).

Saw this issue today and the below on-liner fixes for me.

npm install zone.js@0.8.7 --save 

in firefox works fine

Change “zone.js”:“^0.8.5” to “zone.js”:“0.8.5” the problem disappeared, thanks

i think there is a mixup with npm verisons for zone.js my package.json shows dependencies "zone.js": "^0.8.4"

but inspecting node_modules\zone.js\package.json shows that it’s having different version downloaded by

ng new

"_id": "zone.js@0.8.8",

uninstall zone.js and reinstall zone.js using npm will upgrade it to 0.8.8 instead of 0.8.4 so angular/cli 1.0.0 is pointing to wrong version

in firefox i got this message originalDescGet is undefined

yeah… have to downgrade to zone.js@0.8.5 fix this problem it’s issue with zone.js@0.8.8.

Same issue here. Seems to be a Chromium bug only as Firefox is working fine for me. If I make a production build the error message is gone. Must be something with sockjs-node as the error comes when the xhr request is responding to this call: http://localhost:4200/sockjs-node/info?t=1492854252110

Update: Is this maybe the BrowserSync module? I’m not using sockjs-node in my project.

Update: zone.js want’s to get the property __zone_symbol___ontimeout of an xhr object and this property does not exists.

Update: M’kay, I’ve got something. Maybe. I’m not quite sure though. There is a property getter inside zone.js/dist/zone.js at line 1245. It says that this getter would return null, if the property is unassigned. Well, the timeout property is unassigned in the xhrobject and tries to get it with hasOwnProperty. As this fails it tries to fallback on the originalDescGet-ter. This is however undefined for some reason. (I guess this is the real issue here). If just simply put the originalDescGet in an if statement and return null otherwise, the error message is gone. I’m not posting code for a reason. It would be a bad-bad practice to change a node_module file locally…

Still looking for an easy fix… XD

Same issue here. I tried both node v6.10.2 and node v7.9.0.

Run the following command in your project folder: npm install zone.js@0.8.5 --save http://stackoverflow.com/questions/43556422/angular-2-typeerror-cannot-read-property-apply-of-undefined

With zone.js@0.8.5 the problem disappeared, thanks

Remove caret (^) and downgrade to 0.8.4. This works for me.

“zone.js”: “0.8.4”

I have “zone.js”: “^0.8.5” but problem still persists.

remove the caret, and rm -rf node_modules && rm yarn.lock && yarn

npm install zone.js@0.8.5 --save

Downgrading to zone.js@0.8.5 works

Just a reminder that Angular 4.0.3 works fine with zone.js@0.8.7, as well as 0.8.5 and 0.8.6.

Only zone.js 0.8.8 has the problem of “does not play nice with others” (Angular 4.0.3 to be specific), so do not feel like you have to downgrade all the way back to 0.8.5 as some have suggested. That’s a bit extreme.

Downgraded zone and worked npm install zone.js@0.8.5 --save ng server

same error, with a fresh project… Before: image

Then: 1.edit package.json , check zone.js change version from 0.8.8 to 0.8.5, and save "zone.js": "0.8.5" 2.install the specific version npm install zone.js@0.8.5 3.if everything going well, do npm start 5.Go to your browser localhost:4200 , and (firefox) javascript console don’t show the error. So …are we stack on this version?

uninstall zone.js and reinstall zone.js using npm will upgrade it to 0.8.8 instead of 0.8.4 so angular/cli 1.0.0 is pointing to wrong version

@laiseng the caret (^) is here to automatically pick safe upgrades in a semver way. Just remove the caret if you want to stick this dependency to a specific version.

The latest zone.js@0.8.9 with @angular/cli@1.0.1 and @angular/…@4.1.0 fixes everything for me

zone.js 0.8.9 solved the problem

Got the same error/issue. Version 0.8.7 fixed it for me.

@angular/cli@1.0.0 @agnular@4.0.0 zone.js@0.8.7

Perfect! Back from children duties now. Quick fix is that if you just ‘npm install zone.js@0.8.5’ in the root of the application created by the CLI it fixes the issue 😃

Well done tracking that one down @all.

Same here from this morning in chromium. I tried downgrading to angular 4.0.0 but the problem is still here. I can’t figure what has changed since yesterday.

Closing Fixed by Zonejs Update.

Angular@4.0.3 together with zone@0.8.9, the issue is still here. Checked in Chrome Version 57.0.2987.133 (64-bit) on OSX Sierra 10.12.4

When downgraded zone to 0.8.7 the issue has gone.

screen shot 2017-04-26 at 15 46 59 screen shot 2017-04-26 at 15 47 13 screen shot 2017-04-26 at 15 47 36

@gueroverde I had the same issue, can confirm upgrading zone.js to 0.8.9 fixes it.

+1 zone.js 0.8.9 is ok here. @iainplimmer this issue can be closed IMO.

zone.js downgrade from 0.8.8 to 0.8.7 worked for me

Same here, works in 0.8.7

Thanks! it works with zone.js 0.8.4 😃 😃

The way I upgrade Angular versions (e.g., 4.0.0 to 4.0.3) is to use the (previously installed on my machine) npm-check-updates command:

  1. cd to the directory where package.json is located.
  2. ncu -a
  3. npm install I did this recently and discovered that Angular 4.0.3 works with zone.js 0.8.7 and below but not with zone.js 0.8.8.

FYI: when I create a new project with Angular-cli, I always specify the --skip-install switch as in: ng new something --skip-install --routing --style=css cd something ncu -a npm i

With zone.js@0.8.5 the problem disappeared, thanks

zone.js@0.8.5 is working fine with @angular/*@4.0.3. Thanks.

Having the same problem till yesterday night, glad to see I’m not alone…

Same problem here.

down graded to zone.js@0.8.4 and issue fixed.

I solved with this:

npm install zone.js@0.8.7 --save

is the rigth way?

Ok, I solved it, new projects comes with switched off importing polyfills for IE9, IE10 and IE11 (polyfills.ts), uncommenting to actually import them solved my issue with chromium.

Upgrade @angular/core from ^4.0.0 to ^4.0.3 and then upgrade zone.js to ^0.8.5.

@fmorriso you are right! The version in the file is different from the version shown by npm view zone.js version (thanks). I deleted the folder, run npm update and the version now is 0.8.9, which solves the problem.

kleber-swf: Verify that you really did re-upgrade to zone.js@0.8.8 by checking your equivalent to C:\projects\APM-Start-CLI\node_modules\zone.js\package.json and verify that the 5th line (might be higher or lower) shows the following:

"raw": "zone.js@^0.8.8",

In your case, the “magic recovery to using zone.js@0.8.8” may in fact be using an older edition of zone.js.

To be really certain that zone.js 0.8.8 works, you should delete directory C:\projects\APM-Start-CLI\node_modules\zone.js and then go back and npm install -S zone.js@0.8.8 to verify it has had the miraculous recovery that you mentioned earlier.

My bad @BamiGorengo I made a mistake I put npm install zone.js:@0.8.5 instead of npm install zone.js@0.8.5, without ‘:’. Now I correct it. Try it again with the steps from above.

@iainplimmer No. It is just suppressed. 😂

You have to restart your server after downgrade to zone.js@0.8.4 .

Same Problem here.

Yup Firefox doesn’t give this error as mentioned by kGorozhanov.