Unable to get Ionic 6 and Angular 13 SSR to work - @ionic/angular-server

Hey gang,

We’re having trouble starting a new Ionic 6 project with Angular 13 and server side rendering (SSR).

We’re following Mike Hartington’s Ionic blog post about SSR: Mike’s Post.

Does @ionic/angular-server support SSR with Angular 13? The package.json of that module makes me think it doesn’t.

Our Env Details
Angular CLI: 13.1.2
Node: 16.13.1
Package Manager: npm 8.1.2
OS: darwin arm64

Angular: 13.1.1
… animations, common, compiler, compiler-cli, core, forms
… language-service, platform-browser, platform-browser-dynamic
… platform-server, router

Package Version
@angular-devkit/architect 0.1301.2
@angular-devkit/build-angular 13.1.2
@angular-devkit/core 13.1.2
@angular-devkit/schematics 13.1.2
@angular/cli 13.1.2
@nguniversal/builders 13.0.1
@nguniversal/express-engine 13.0.1
@schematics/angular 13.1.2
rxjs 6.6.7
typescript 4.4.4

Ionic: 6.18.1
@ionic/angular-server: “6.0.1”
@nguniversal/express-engine: “^13.0.1”

The Errors
When we follow the install steps and then run npm run dev:ssr, we get this error:

We found a solution to this on Github: Ionic 5 SSR not working · Issue #4773 · ionic-team/ionic-cli · GitHub
Basically, we need to modify the angular.json to include ‘development’ entries.

The server will spin up and we can access localhost:4200. When we hit the page, it loads and doesn’t have any errors in the dev console. However, in our terminal, we get these errors:

After adding IonicServerModule to the app.server.module.ts imports, we re-run npm run dev:ssr.

The build fails with these errors:

We haven’t be able to figure out a workaround beyond this point :frowning_face:.

We were able to get ionic and angular SSR working by running this repo, but it’s using much older versions of angular, ionic, and ionic/angular-server. We’d like to avoid having to use older versions.

Any advice on getting this spun up in our environment?


Chipping in with no solution

Oh bummer. I appreciate the heads up!

As a side note, for your issue, if you follow the guide in github issue #4773 that I linked, it’ll solve that error. Not that it’s worth much because it sounds like you’re going to run into my errors after that.

1 Like