npm 安装ng add @ng-bootstrap/ng-bootstrap时出错

ilmyapht  于 2023-05-07  发布在  Bootstrap
关注(0)|答案(9)|浏览(146)

安装ng-bootstrap到我的Angular-CLI(11.0.4)时出现错误。什么时候

ng add @ng-bootstrap/ng-bootstrap

还有我的日志文件

[error] Error: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: front@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~11.0.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.1" from @angular/localize@11.1.1
npm ERR! node_modules/@angular/localize
npm ERR!   peer @angular/localize@"^11.0.0" from @ng-bootstrap/ng-bootstrap@9.0.2
npm ERR!   node_modules/@ng-bootstrap/ng-bootstrap
npm ERR!     @ng-bootstrap/ng-bootstrap@"*" 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/damika/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/damika/.npm/_logs/2021-02-02T16_41_53_338Z-debug.log
Package install failed, see above.
    at Object.installPackage (/home/damika/Desktop/CACHE/School/Front/node_modules/@angular/cli/utilities/install-package.js:40:15)
    at AddCommand.run (/home/damika/Desktop/CACHE/School/Front/node_modules/@angular/cli/commands/add-impl.js:149:31)
    at async AddCommand.validateAndRun (/home/damika/Desktop/CACHE/School/Front/node_modules/@angular/cli/models/command.js:139:28)
    at async Object.runCommand (/home/damika/Desktop/CACHE/School/Front/node_modules/@angular/cli/models/command-runner.js:204:24)
    at async default_1 (/home/damika/Desktop/CACHE/School/Front/node_modules/@angular/cli/lib/cli/index.js:80:31)

终端出错

An unhandled exception occurred: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: front@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~11.0.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.1" from @angular/localize@11.1.1
npm ERR! node_modules/@angular/localize
npm ERR!   peer @angular/localize@"^11.0.0" from @ng-bootstrap/ng-bootstrap@9.0.2
npm ERR!   node_modules/@ng-bootstrap/ng-bootstrap
npm ERR!     @ng-bootstrap/ng-bootstrap@"*" 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/damika/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/damika/.npm/_logs/2021-02-02T16_38_17_817Z-debug.log
Package install failed, see above.
See "/tmp/ng-qJ50sG/angular-errors.log" for further details.
(base) damika@damiboy:~/Desktop/CACHE/School/Front/src/app$ ng update
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 28 dependencies.
    Invalid response body while trying to fetch https://registry.npmjs.org/@angular%2fcommon: aborted
    We analyzed your package.json, there are some packages to update:
    
      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cli                       11.0.7 -> 11.1.2         ng update @angular/cli
      @angular/core                      11.0.9 -> 11.1.1         ng update @angular/core
    
    There might be additional packages which don't provide 'ng update' capabilities that are outdated.
    You can update the additional packages by running the update command of your package manager.
(base) damika@damiboy:~/Desktop/CACHE/School/Front/src/app$ ng add @ng-bootstrap/ng-bootstrap 
Installing packages for tooling via npm.
An unhandled exception occurred: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: front@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~11.0.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.1" from @angular/localize@11.1.1
npm ERR! node_modules/@angular/localize
npm ERR!   peer @angular/localize@"^11.0.0" from @ng-bootstrap/ng-bootstrap@9.0.2
npm ERR!   node_modules/@ng-bootstrap/ng-bootstrap
npm ERR!     @ng-bootstrap/ng-bootstrap@"*" 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/damika/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/damika/.npm/_logs/2021-02-02T16_41_53_338Z-debug.log
Package install failed, see above.
See "/tmp/ng-ySkXlt/angular-errors.log" for further details.

任何人都可以帮助我;谢谢你的帮助:)

jaxagkaj

jaxagkaj1#

试试用这个
npm config set legacy-peer-deps true
这允许安装旧版软件包
如果你是Linux用户尝试在命令的开头添加sudo

zbq4xfa0

zbq4xfa02#

ng update @angular/cli @angular/core

你只需要更新angular,对我来说很好用,但是你需要在之前提交,然后再做一次,这和“npm i”到“ng add”是不一样的第二个有原理图,这样安装就更容易了

ng add @ng-bootstrap/ng-bootstrap
mec1mxoz

mec1mxoz3#

尝试使用npm i @ng-bootstrap/ng-bootstrap,它将解决您的问题

n6lpvg4x

n6lpvg4x4#

执行以下命令。这是我的问题的解决方案。

npm i @ng-bootstrap/ng-bootstrap --legacy-peer-deps

oiopk7p5

oiopk7p55#

按顺序运行以下命令以更新angular CLI并在项目中安装ng-bootstrap。
ng update @angular/cli @angular/core
npm install --save @ng-bootstrap/ng-bootstrap

qeeaahzv

qeeaahzv6#

我最近遇到了@angular-eslint/schematics的问题。我用npm安装了这个包,然后用ng安装了dep:

npm install @angular-eslint/schematics --legacy-peer-deps
ng add @angular-eslint/schematics
blpfk2vs

blpfk2vs7#

希望这能帮助到一些人

npm i  --save @ng-bootstrap/ng-bootstrap --legacy-peer-deps

它解决了我问题

nwsw7zdq

nwsw7zdq8#

添加此命令,您的问题将得到解决:
npm i @ng-bootstrap/ng-bootstrap --legacy-peer-deps

enyaitl3

enyaitl39#

npm install @ng-bootstrap/ng-bootstrap@next,可以正常工作

相关问题