Uncaught TypeError: Cannot read property 'apply' of undefined on new install
Bug Report or Feature Request (mark with an x)
- [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.
Same here. Had t downgrade to zone.js 0.8.5 as @JoseIgor mentioned.
Freeze to 0.8.5 helped , thanks @JoseIgor
Downgraded zone and worked npm install [email protected] --save ng server
Angular-cli generated app subsequently upgraded (via npm-check-updates - ncu -a ) to latest packages, including angular 4.0.3 and zone.js 0.8.8 fails as previously described.
downgrading from zone.js 0.8.8 to zone.js 0.8.5 - error disappears during ng serve --open
downgrading from zone.js 0.8.8 to zone.js 0.8.6 - error disappears during ng serve --open
downgrading from zone.js 0.8.8 to zone.js 0.8.7 - error disappears during ng serve --open
conclusion: angular 4.0.3 and zone.js 0.8.8 are not compatible.
same error, with a fresh project...
Before:

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 [email protected]
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?
Run the following command in your project folder:
npm install [email protected] --save
http://stackoverflow.com/questions/43556422/angular-2-typeerror-cannot-read-property-apply-of-undefined
but it just works fine in firefox.
How do you upgrade to 4.0.3 ? I'm having the same issues on 4.0.0 and zone.js 0.8.4
Same here.. after upgrading to v0.8.8
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:
- cd to the directory where package.json is located.
- ncu -a
- 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
+1
npm install [email protected] --save
Thanks! it works with zone.js 0.8.4 :) :)
with [email protected] the problem disappeared. Removes the node_modules folder and runs the npm install command again.
Same situation/solution here: zone 0.8.5 worked for me!
Just a reminder that Angular 4.0.3 works fine with [email protected], 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.
Same here, works in 0.8.7
I tried that, not even fresh new app is not working. I tried couple of times to remove angular/cli and angular-cli globally, multiple times local node_modules. Tried to run ng serve globally and locally same error in chromium, but older project runs there fine. I think I need to run it in chromium as some of my target devices are build on it.
Also I noticed that npm show zone.js version shows globally installed version 0.8.8 (not obvious for me npm noob). Tried to uninstall it and clean cache, but another lookup and 0.8.8 still there, at least in some deeper cache? Could not find it in .npm/ nor in .nvm/versions/node/v7.5.0/node_packages. And npm list | grep zone prints [email protected] as angular/clie dep. and [email protected] as project dep. (my fixed version). The older working project has these the same.
I even tried to copy&paste node_modules from thw working project and install rest of the deps. Also I tried to copy&paste dist/ of zone.js unproven fix. - same error.
I don't know what to do next maybe complete reinstall node+npm+nvm and start from clean slate, but it seems rather extreme.
@sangecz What version you did you select in "package.json" ? if zone.js is not version 0.8.8, npm install again should be fine.