Skip to content

SSR not working with ng #10635

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

Closed
deebloo opened this issue May 4, 2018 · 13 comments
Closed

SSR not working with ng #10635

deebloo opened this issue May 4, 2018 · 13 comments

Comments

@deebloo
Copy link
Contributor

deebloo commented May 4, 2018

Versions

Angular CLI: 6.0.0
Node: 8.11.0
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

Observed behavior

A 500 errors occurs

TypeError: StaticInjectorError[InjectionToken Application Initializer -> InjectionToken DocumentToken]:
  StaticInjectorError(Platform: core)[InjectionToken Application Initializer -> InjectionToken DocumentToken]:
    Right-hand side of 'instanceof' is not an object
    at bt (/Users/dannyblue/Documents/projects/foo/dist/server.js:1182:87380)
    at gt (/Users/dannyblue/Documents/projects/foo/dist/server.js:1182:87255)
    at ir (/Users/dannyblue/Documents/projects/foo/dist/server.js:1182:110026)

Desired behavior

App is served correctly

Mention any other details that might be useful (optional)

This works fine with Angular 6 and Angular CLI 1.7 but fails with Angular 6 and Angular CLI 6.

@deebloo
Copy link
Contributor Author

deebloo commented May 4, 2018

I saw a couple of other issues but they seem tied to 1.7 where 1.7 was working fine for me. #8616

@ArthurBrito
Copy link

SSR is not working with CLI 6 you'll run into a StaticInjectorError, until they fix you you could downgrade the CLI (npm install @angular/[email protected] )

@deebloo
Copy link
Contributor Author

deebloo commented May 4, 2018

that is what I figured. just wanted to make sure there was a clear easy repro. 1.7 still works fine but bundles will be a bit bigger with rxjs6 and no webpack 4

@naveedahmed1
Copy link

@deebloo is it also about

--bundle-dependencies=all

@filipesilva
Copy link
Contributor

Heya, I think this is a duplicate of #8616, or at least the same root cause. It hasn't been addressed yet. I will bump it's priority.

@deebloo
Copy link
Contributor Author

deebloo commented May 4, 2018

cool deal thanks @filipesilva

@naveedahmed1
Copy link

Thank you so much @filipesilva let's hope it gets fixed soon.

@paulogr
Copy link

paulogr commented May 5, 2018

I did solve this issue changing my webpack.server.config.js mode to development instead of production

Hope it helps

Angular CLI: 6.0.0
Node: 8.9.4
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.7.0

@lukaszzieba
Copy link

For me works just copy webpack.server.config.js from https://angular.io/guide/universal

@johnzondr
Copy link

Hey guys,

Similar to what @paulogr said, this error occurred for me when webpack minimizes the file (production mode). By turning minimization off, the 500 error no longer occurs.

My webpack config:
https://gist.github.com/johnzondr/3d4a361ffcfe89f7ee5199dcc13bf246

@JohnHe404
Copy link

JohnHe404 commented Dec 28, 2018

I copy webpack.server.config.js from https://angular.io/guide/universal , Still have problems.
But I copy webpack.server.config.js from https://snipcart.com/blog/angular-seo-universal-server-side-rendering,fix this problems.

@johnzondr
Copy link

@HeMinzhang that configuration is working because it is forcing webpack's mode to none as opposed to production. This turns off minimization (the culprit), but it would also turns off EVERY other optimization for production.

see: https://webpack.js.org/concepts/mode/

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants