emme
emme

Reputation: 101

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! 

Upvotes: 8

Views: 3190

Answers (3)

Yunus Yerli
Yunus Yerli

Reputation: 124

you need to code as below:

npm install @nguniversal/express-engine --legacy-peer-deps

After it will install node_modules but not required files. To do this:

ng add @nguniversal/express-engine

This will say "The package already installed". Ignore this and wait to see required SSR files.

Upvotes: 1

achim2
achim2

Reputation: 51

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

Upvotes: 3

Muhammad Jamaluddin
Muhammad Jamaluddin

Reputation: 91

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:

Upvotes: 9

Related Questions