'Failed install Angular Universal in my angular13 app

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! 


Solution 1:[1]

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:

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 achim2