Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed install Angular Universal in my angular13 app

Tags:

npm

angular

I am trying to install @nguniversal/[email protected] in my angular 13 app but I get some errors. Anyone can help me?

Angular CLI: 13.0.4 Node: 16.13.1 Package Manager: npm 8.1.2

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/animations
npm ERR!   @angular/animations@"~13.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/animations@"13.1.0" from @angular/[email protected]
npm ERR! node_modules/@angular/platform-server
npm ERR!   peer @angular/platform-server@"^13.0.1" from @nguniversal/[email protected]
npm ERR!   node_modules/@nguniversal/express-engine
npm ERR!     @nguniversal/express-engine@"13.0.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
like image 604
emme Avatar asked Jun 16 '26 22:06

emme


2 Answers

Try this, worked for me.

I followed the steps and able to achieve the same.

  1. Run npm i @nguniversal/express-engine, if throws error try to run with --force.
  2. ng generate universal --project=<project_name>

Useful Links:

  • https://www.npmjs.com/package/@nguniversal/express-engine
  • https://angular.io/guide/universal
  • https://github.com/chrisjwalk/angular-cli-netcore-ngrx-starter/issues/1#issuecomment-397814345
  • reinstall angular universal after angular cli upgrade
  • https://stackoverflow.com/a/67739645/17680410
  • Angular Server Side Rendering - What to add to angular.json?
like image 115
Muhammad Jamaluddin Avatar answered Jun 18 '26 12:06

Muhammad Jamaluddin


I had this problem too but the '--force' is not a good idea. So I think the ng wants to upgrade @angular/animations but it has peer dependencies with another angular modules. So I tried to update the whole angular project.

https://update.angular.io/

npx @angular/cli@13 update @angular/core@13 @angular/cli@13

Try to update your project with this code then you can install a new package with ng

like image 22
achim2 Avatar answered Jun 18 '26 11:06

achim2