【问题标题】:unable to install the bootstrap无法安装引导程序
【发布时间】:2022-01-06 13:41:17
【问题描述】:

我无法将 ng 引导程序安装到我的项目中。我不断收到以下错误。

我已经尝试运行以下命令,但仍然没有成功。

  1. npm install --legacy-peer-deps
  2. npm install latest-version

以下是我正在使用的版本: 角 CLI:12.0.3 节点:14.17.5 包管理器:npm 8.3.0

huss@Huss-MacBook-Air huss_web % ng 添加@ng-bootstrap/ng-bootstrap
您的全局 Angular CLI 版本 (12.2.2) 高于本地版本 (12.0.3)。使用本地 Angular CLI 版本。

要禁用此警告,请使用“ng config -g cli.warnings.versionMismatch false”。 ℹ 使用包管理器:npm ✔ 找到兼容的包版本:@ng-bootstrap/ng-bootstrap@10.0.0。 ✔ 已加载包裹信息。

The package @ng-bootstrap/ng-bootstrap@10.0.0 will be installed and executed.
Would you like to proceed? Yes
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: huss-web@0.0.0
npm ERR! Found: @angular/compiler@12.0.5
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~12.0.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"12.2.15" from @angular/localize@12.2.15
npm ERR! node_modules/@angular/localize
npm ERR!   peer @angular/localize@"^12.0.0" from @ng-bootstrap/ng-bootstrap@10.0.0
npm ERR!   node_modules/@ng-bootstrap/ng-bootstrap
npm ERR!     @ng-bootstrap/ng-bootstrap@"10.0.0" 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 /Users/hussainsamiwala/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/hussainsamiwala/.npm/_logs/2022-01-05T18_56_39_213Z-debug-0.log
✖ Package install failed, see above.
hussainsamiwala@Hussains-MacBook-Air huss_web % 

我的 package.json 如下:

{
  "name": "huss-web",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.0.3",
    "@angular/cdk": "^12.1.0",
    "@angular/common": "~12.0.3",
    "@angular/compiler": "~12.0.3",
    "@angular/core": "~12.0.3",
    "@angular/forms": "~12.0.3",
    "@angular/google-maps": "^12.1.0",
    "@angular/material": "^12.1.0",
    "@angular/platform-browser": "~12.0.3",
    "@angular/platform-browser-dynamic": "~12.0.3",
    "@angular/router": "~12.0.3",
    "@googlemaps/js-api-loader": "^1.12.1",
    "@types/jquery": "^3.5.6",
    "angular-ui-bootstrap": "^2.5.6",
    "bootstrap": "^5.1.0",
    "jquery": "^3.6.0",
    "jquery-ui": "^1.13.0",
    "latest-version": "^6.0.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.1.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.0.3",
    "@angular/cli": "~12.0.3",
    "@angular/compiler-cli": "~12.0.3",
    "@types/google.maps": "^3.45.6",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.7.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "typescript": "~4.2.3"
  }
}

【问题讨论】:

  • 你可以试试ng add @ng-bootstrap/ng-bootstrap@10.0.0

标签: angular npm bootstrap-4


【解决方案1】:

尝试使用--force--legacy-peer-deps 运行命令

【讨论】:

    【解决方案2】:

    你可以试试这个命令。

    npm i @ng-bootstrap/ng-bootstrap
    

    【讨论】:

      【解决方案3】:

      试试这个:

      删除 node_modules 文件夹

      npm install --force
      
      ng add @ng-bootstrap/ng-bootstrap
      
      

      【讨论】:

      • 我尝试了上述所有建议的选项,但仍然没有运气。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-26
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      相关资源
      最近更新 更多