简体   繁体   中英

Cannot install ng zorro with angular cli

I can't install ng-zorro. When I run the ng add ng-zorro-antd command, I get an error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: money-watch-f@0.0.0
npm ERR! Found: @angular/animations@12.0.5
npm ERR! node_modules/@angular/animations
npm ERR!   @angular/animations@"~12.0.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/animations@"^12.1.0" from ng-zorro-antd@12.0.1
npm ERR! node_modules/ng-zorro-antd
npm ERR!   ng-zorro-antd@"*" 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! 
npm ERR! See /home/adrian/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/adrian/.npm/_logs/2021-08-12T20_18_56_738Z-debug.log
✖ Package install failed, see above.

ng v info:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.0.5
Node: 14.17.5
Package Manager: npm 7.20.5
OS: linux x64

Angular: 12.2.1
... cdk, core, material

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.1200.5
@angular-devkit/build-angular       12.0.5
@angular-devkit/core                12.0.5
@angular-devkit/schematics          12.0.5
@angular/animations                 12.0.5
@angular/cli                        12.0.5
@angular/common                     12.0.5
@angular/compiler                   12.0.5
@angular/compiler-cli               12.0.5
@angular/forms                      12.0.5
@angular/platform-browser           12.0.5
@angular/platform-browser-dynamic   12.0.5
@angular/router                     12.0.5
@schematics/angular                 12.0.5
rxjs                                6.6.7
typescript                          4.2.4

What could be the cause and how to solve it? I'm using Ubuntu 20.04

  1. npm install --save --legacy-peer-deps
  2. npm config set legacy-peer-deps true
  3. npm cache clean --force
  4. check node.js version downgrade if it is required or use LTS version

Note: 2nd option was worked to me

  1. upgrade angular components to ~12.1.0 in the package.json.
  2. remove package.lock and run npm install to install deps.
  3. run ng add ng-zorro-antd to install ng-zorro.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM