I’m trying to set up Firebase with Angular for server-side rendering but running into issues. When I try to install the required packages using npm install --save-dev @nguniversal/express-engine @nguniversal/module-map-ngfactory-loader express webpack-cli ts-loader ws xhr2, I keep getting this dependency error:
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^8.2.0" from @nguniversal/[email protected]
npm ERR! node_modules/@nguniversal/module-map-ngfactory-loader
npm ERR! dev @nguniversal/module-map-ngfactory-loader@"*" from the root project
I’m not sure if this is something I’m doing wrong with my setup or if there’s a version compatibility issue. Has anyone encountered this before? Are there any ways to fix this dependency conflict?
Had this exact problem migrating an older Angular project. @nguniversal/module-map-ngfactory-loader got deprecated after Angular 8 and won’t work with newer versions. Don’t try forcing those packages - check your package.json for your Angular version first. Angular 14+ has built-in Universal support. Just run ng add @nguniversal/express-engine and it’ll handle everything automatically. No manual dependency setup needed. The command detects your version and grabs the right Universal packages. Saved me hours of debugging dependency hell.
This happens when you’re mixing Angular Universal packages from different major versions. The @nguniversal/module-map-ngfactory-loader package is for Angular 8, but you’re probably running a newer version. I hit this same issue upgrading an old project. Don’t use --legacy-peer-deps to force it - update your command to use the right Universal packages instead. For Angular 13+, run ng add @nguniversal/express-engine and it’ll automatically install compatible versions. If you’re on Angular 12, use npm install @nguniversal/express-engine@12 @nguniversal/builders@12. You’ll avoid runtime issues from version mismatches this way.
yea, it does seem like a version conflict. run ng version to see what version of Angular u have. if it’s 12 or higher, go for @nguniversal/[email protected] to match.