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

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

Open iainplimmer opened this issue 9 years ago • 103 comments

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.

iainplimmer avatar Apr 22 '17 07:04 iainplimmer

Make sure you restart your application instead of just reloading the webpage ;)

Klyner007 avatar Apr 25 '17 13:04 Klyner007

FWIW, working fine on newest versions of: node: v7.9.0 angular-cli: 1.0.1 @angular/common: 4.0.3 Got from ncu -a But manually downgrading zone to 0.8.7: npm i -S [email protected] Consider removing caret on package.json as on commit above to avoid install zone.js 0.8.8 on later npm installs.

berardo avatar Apr 25 '17 13:04 berardo

For whatever it's worth, it works in Microsoft Edge :)

peterbarraud avatar Apr 25 '17 13:04 peterbarraud

I had the same issue, downgraded to zone.js to 0.8.7 and it worked. I just upgraded to 0.8.8 again (actually ^0.8.7) to test and still works! I've tested on Chrome, Firefox and Edge. Go figure...

kleber-swf avatar Apr 25 '17 14:04 kleber-swf

kleber-swf: Verify that you really did re-upgrade to [email protected] 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 [email protected]" 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 [email protected] to verify it has had the miraculous recovery that you mentioned earlier.

fmorriso avatar Apr 25 '17 15:04 fmorriso

zone.js 0.8.5 solved the problem. Thanks.

MohammedEssehemy avatar Apr 25 '17 16:04 MohammedEssehemy

zone.js 0.8.9 solved the problem

willyhakim avatar Apr 25 '17 18:04 willyhakim

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

mpalourdio avatar Apr 25 '17 19:04 mpalourdio

@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 avatar Apr 25 '17 19:04 kleber-swf

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

bezerrath avatar Apr 25 '17 21:04 bezerrath

I tried to install @angular/cli on my debian server (no prev angular, angular/cli or whatever installed). I generated test app with ng new zonetest and run it with ng build. Then I hosted the dist/ dir with python -m SimpleHTTPServer. And in chrome, firefox and safari its working fine. But in chromium I get this error (same as on my machine): screen shot 2017-04-25 at 23 38 04

screen shot 2017-04-25 at 23 38 39

I think that this error has nothing to do with zone.js. I don't know what to do, I really need this working in that damn chromium, and I know it worked...

sangecz avatar Apr 25 '17 21:04 sangecz

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.

sangecz avatar Apr 25 '17 23:04 sangecz

I solved with this:

npm install [email protected] --save

is the rigth way?

gueroverde avatar Apr 26 '17 05:04 gueroverde

@gueroverde It looks like this is fixed in the latest release (0.8.9) too

M-R-Bishop avatar Apr 26 '17 05:04 M-R-Bishop

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

hexagon6 avatar Apr 26 '17 11:04 hexagon6

[email protected] together with [email protected], 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

anatoly314 avatar Apr 26 '17 12:04 anatoly314

The latest [email protected] with @angular/[email protected] and @angular/[email protected] fixes everything for me

Tyrix avatar Apr 26 '17 19:04 Tyrix

I confirm, I cannot reproduce with [email protected], @angular/[email protected] and @angular/[email protected]

aguacongas avatar Apr 27 '17 08:04 aguacongas

Closing Fixed by Zonejs Update.

sumitarora avatar Apr 27 '17 15:04 sumitarora

I've tried all node.js versions and I'm still getting a similar error. I'm now on the latest 0.8.11, and everything else is pretty much the latest version.

ERROR TypeError: Cannot read property 'apply' of undefined
    at Up (ima3.js:687)
    at Sp.L (ima3.js:688)
    at Ig (ima3.js:470)
    at R (ima3.js:468)
    at Ep.B (ima3.js:678)
    at Fg (ima3.js:465)
    at Bg (ima3.js:466)
    at ima3.js:464
    at ZoneDelegate.invokeTask (zone.js:424)
    at Object.onInvokeTask (core.es5.js:4140)

So it seems to be an issue on here:

        ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) {
            return this._invokeTaskZS ?
                this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) :
                task.callback.apply(applyThis, applyArgs);
        };

Anyone has any ideas?

dfanica avatar May 31 '17 09:05 dfanica