New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 9: Window is not defined #1523
Comments
Problem was related to hammerjs, after changed it on @egjs/hammerjs solution is building |
@MDzyga how is that? I'm having the same error with this component https://www.npmjs.com/package/ngx-device-detector the issue is:
Any ideas? |
with previous angular 8.x version, that worked perfectly. |
Your problem is not related to webpack, only to define window in server.ts file. |
Hello @MDzyga I'm not using webpack and I know that, I've already defined window in server.ts file. I don't understand why this issue arise again in angular 9, I'm using domino to get the globals, something like: server.ts fragment:
|
They changed a lot of things in angular.
|
|
@BruneXX I'm using too ngx-device-detector and check if you declare this module in app.module. Later I don't check the platform and only use deviceDetectorService to do it, but maybe in your case is necessary to do it. |
Hi @MDzyga, mmm that's wierd, yes it's set before the express call |
Hi @MDzyga I've performed some changes in server.ts now I'm receiving errors about not found any module, I've checked out in a started package and it seems that tsconfig.server.ts and tsconfig.app.ts haven't set the baseUrl property anymore, is that correct? |
Hi, you need to set baseUrl on app folder. I noticed Angular changed in angular.json main file. Earlier I set on main.server.ts but now I had to set sever.ts. |
No, I'm not using angular-cli, do you have an example of your baseUrl? I've in my tsconfig.ts file baseUrl: './src' |
tsconfig.ts -> baseUrl: 'src' but server.ts was changed in the latest version of angular universal.
|
@MDzyga thanks! I've changed to match with your server.ts and tsconfig.ts my server.ts was 90% different before migration, Now I've to made some minor changes to match yours I hope this works, otherwise IDK how to fix the lot of |
Yes, I've already done that in v8.x |
Hi @MDzyga after a lot of changes in tsconfig files I've managed to reach to a new error xD
Have you experienced something similar? Thanks! |
I'd to validate that |
I didn't have this problem |
now I've the issue that is that I cannot serve (with node) angular universal... the commnad |
Also I've tried specifically with full path to file... |
I'm using angular cli so maybe this package changes something |
Can you share how you serve the universal app after build? |
Regarding this: https://trilon.io/blog/angular-universal-v9-whats-new is still the same... just |
Check angular.json settings.
I serve my app executing
|
@MDzyga I checked your repo, where did you define the webpack.config.js in your code? It seems like you are not using it. I'm facing a problem that is related to webpack loaders, I can define ts-loader in webpack.config.js but how can I define it in server.ts or cli? I'm wondering how you built the project using webpack.config.js without using custom builders in cli. |
I'm using Angular cli and currently it doesn't need custom webpack to build an application |
But how without using any special loaders? I'm getting this error |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Description
I'm trying to migrate my solution to the latest angular universal version from AU 8 and during execute npm run dev:ssr I get an error:
In previous version of server.ts my collegue figure it out like below:
How should I set 'window' in the latest version of AU?
🔥 Exception or Error
🌍 Your Environment
"@angular/animations": "^9.0.2",
"@angular/cdk": "^9.0.1",
"@angular/common": "^9.0.2",
"@angular/compiler": "^9.0.2",
"@angular/core": "^9.0.2",
"@angular/forms": "^9.0.2",
"@angular/material": "^9.0.1",
"@angular/platform-browser": "^9.0.2",
"@angular/platform-browser-dynamic": "^9.0.2",
"@angular/pwa": "^0.900.3",
"@angular/router": "^9.0.2",
"@angular/service-worker": "^9.0.2",
"@nguniversal/common": "^9.0.1",
"@nguniversal/express-engine": "^9.0.1",
The text was updated successfully, but these errors were encountered: