-
Notifications
You must be signed in to change notification settings - Fork 518
Angular Template: EXCEPTION: Uncaught (in promise): ReferenceError: window is not defined #323
Comments
Unfortunately If it's further along in your App, you'll want to do something like:
We're working on at mocking/fixing certain things such as |
@MarkPieszak is correct, but can I also clarify with @hheexx: are you saying that the same application code used to work without errors before you updated to the newer template? If so, could you post more information about where your code is accessing |
No, my code does not access the window, that is a problem :) I use identical boot-server.ts from template. As you can see whole stack is in zone-node.js so I don't understand what part of code may be responsible. I'm not that good with angular2 troubleshooting yet. Also, where I can find transpiled js files on server? |
@hheexx Did you wipe your node_modules folder and try reinstalling again? |
yes, multiple times. Node 6.4.0 |
Does this call stack mean anything to you? |
Is this a completely default new Repo or do you have code in there? ( Lazy-loading routes or anything new and specific that might be causing it) I'm looking into it! |
It has 10-20 components but all are without js for now, just HTML. |
I'm afraid I don't know based on the call stack alone. Can you supply details on how to repro the issue starting from a new project? |
Ok, my bad. I just found piece of code that breaks and it's mine. Code is in App component and it scrolls to top of page on view change: router.events.subscribe(s => { Now i wrapped it with if (IsBrowser) {..} and it works great but have in mind that this observable was not triggered before on the server and now it does. Don't know why. Please close the bug if you think that this behavior change does not need fixing... |
I can only guess this is to do with you now running on Angular 2 final, which is quite different internally than Angular 2 RC4. Besides that major change, these templates work the same at runtime as they did before :) |
Nope. |
Ah OK, thanks for clarifying. I don't know why changing the file layout in the way I did would have this effect. |
isBrowser??? What module should I import to use this? |
angular2-universal |
After updating all files to newest template I receive this stack trace in server console:
fail: Microsoft.AspNetCore.NodeServices[0]
EXCEPTION: Uncaught (in promise): ReferenceError: window is not defined
fail: Microsoft.AspNetCore.NodeServices[0]
ORIGINAL STACKTRACE:
fail: Microsoft.AspNetCore.NodeServices[0]
Error: Uncaught (in promise): ReferenceError: window is not defined
at resolvePromise (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:418:31)
at C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:454:17
at ZoneDelegate.invokeTask (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:225:37)
at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (C:\Users\hexbo\Documents\cx_public\node_modules@angular\core\bundles\core.umd.js:6233:41)
at ZoneDelegate.invokeTask (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:224:42)
at Zone.runTask (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:125:47)
at drainMicroTaskQueue (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:357:35)
at runMicrotasksCallback (internal/process/next_tick.js:58:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
fail: Microsoft.AspNetCore.NodeServices[0]
Unhandled Promise rejection: window is not defined ; Zone: angular ; Task: Promise.then ; Value: ReferenceError: window is not defined
at SafeSubscriber._next (C:\Users\hexbo\Documents\cx_public\ClientApp\boot-server.js:6:27799)
at SafeSubscriber.__tryOrUnsub (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:223:16)
at SafeSubscriber.next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:172:22)
at Subscriber._next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:125:26)
at Subscriber.next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:89:18)
at Subject.next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subject.js:55:25)
at resolveData$.forEach.then._this.navigated (C:\Users\hexbo\Documents\cx_public\node_modules@angular\router\bundles\router.umd.js:2650:44)
at ZoneDelegate.invoke (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:192:28)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (C:\Users\hexbo\Documents\cx_public\node_modules@angular\core\bundles\core.umd.js:6242:41)
at ZoneDelegate.invoke (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:191:34) ReferenceError: window is not defined
at SafeSubscriber._next (C:\Users\hexbo\Documents\cx_public\ClientApp\boot-server.js:6:27799)
at SafeSubscriber.__tryOrUnsub (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:223:16)
at SafeSubscriber.next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:172:22)
at Subscriber._next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:125:26)
at Subscriber.next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subscriber.js:89:18)
at Subject.next (C:\Users\hexbo\Documents\cx_public\node_modules\rxjs\Subject.js:55:25)
at resolveData$.forEach.then._this.navigated (C:\Users\hexbo\Documents\cx_public\node_modules@angular\router\bundles\router.umd.js:2650:44)
at ZoneDelegate.invoke (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:192:28)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (C:\Users\hexbo\Documents\cx_public\node_modules@angular\core\bundles\core.umd.js:6242:41)
at ZoneDelegate.invoke (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:191:34)
fail: Microsoft.AspNetCore.NodeServices[0]
{ Error: Uncaught (in promise): ReferenceError: window is not defined
at resolvePromise (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:418:31)
at C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:454:17
at ZoneDelegate.invokeTask (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:225:37)
at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (C:\Users\hexbo\Documents\cx_public\node_modules@angular\core\bundles\core.umd.js:6233:41)
at ZoneDelegate.invokeTask (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:224:42)
at Zone.runTask (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:125:47)
at drainMicroTaskQueue (C:\Users\hexbo\Documents\cx_public\node_modules\zone.js\dist\zone-node.js:357:35)
at runMicrotasksCallback (internal/process/next_tick.js:58:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
fail: Microsoft.AspNetCore.NodeServices[0]
The text was updated successfully, but these errors were encountered: