运行npm i时无法解析依赖关系

vhmi4jdf  于 2022-11-24  发布在  其他
关注(0)|答案(1)|浏览(154)

运行npm i命令时出现下一个错误:

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: ngx-webstorage@2.0.1
npm ERR! Found: @angular/core@6.1.0
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"6.1.0" from the root project
npm ERR!   peer @angular/core@"6.1.0" from @angular/common@6.1.0
npm ERR!   node_modules/@angular/common
npm ERR!     @angular/common@"6.1.0" from the root project
npm ERR!     peer @angular/common@"6.1.0" from @angular/forms@6.1.0
npm ERR!     node_modules/@angular/forms
npm ERR!       @angular/forms@"6.1.0" from the root project
npm ERR!       1 more (@ng-bootstrap/ng-bootstrap)
npm ERR!     9 more (@angular/platform-browser, ...)
npm ERR!   13 more (@angular/forms, @angular/platform-browser, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"^5.0.0" from ngx-webstorage@2.0.1
npm ERR! node_modules/ngx-webstorage
npm ERR!   ngx-webstorage@"2.0.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/core@5.2.11
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"^5.0.0" from ngx-webstorage@2.0.1
npm ERR!   node_modules/ngx-webstorage
npm ERR!     ngx-webstorage@"2.0.1" from the root project

我尝试删除node_modules目录并重新运行npm i,但没有成功。我也尝试重新安装NodeJS,但没有解决这个错误。
我完全不知道发生了什么。这个命令一直起着很好的作用。
这是我的包裹

"dependencies": {
    "@angular/common": "6.1.0",
    "@angular/compiler": "6.1.0",
    "@angular/core": "6.1.0",
    "@angular/forms": "6.1.0",
    "@angular/platform-browser": "6.1.0",
    "@angular/platform-browser-dynamic": "6.1.0",
    "@angular/router": "6.1.0",
    "@fortawesome/angular-fontawesome": "^0.3.0",
    "@fortawesome/fontawesome-svg-core": "1.2.2",
    "@fortawesome/free-solid-svg-icons": "5.2.0",
    "@ng-bootstrap/ng-bootstrap": "3.0.0",
    "bootstrap": "4.1.3",
    "core-js": "2.5.7",
    "moment": "2.22.2",
    "ng-jhipster": "0.5.4",
    "ngx-cookie": "2.0.1",
    "ngx-infinite-scroll": "0.5.1",
    "ngx-webstorage": "2.0.1",
    "reflect-metadata": "0.1.12",
    "rxjs": "6.1.0",
    "rxjs-compat": "6.1.0",
    "swagger-ui": "2.2.10",
    "tslib": "1.9.3",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "6.1.2",
    "@angular/compiler-cli": "6.1.0",
    "@ngtools/webpack": "6.0.0",
    "@types/jest": "22.2.3",
    "@types/node": "9.4.7",
    "angular-router-loader": "0.8.5",
    "angular2-template-loader": "0.6.2",
    "browser-sync": "^2.27.7",
    "browser-sync-webpack-plugin": "2.2.2",
    "cache-loader": "1.2.2",
    "codelyzer": "4.2.1",
    "copy-webpack-plugin": "4.5.1",
    "css-loader": "0.28.10",
    "exports-loader": "0.7.0",
    "extract-text-webpack-plugin": "4.0.0-beta.0",
    "file-loader": "1.1.11",
    "fork-ts-checker-webpack-plugin": "0.4.1",
    "friendly-errors-webpack-plugin": "1.7.0",
    "generator-jhipster": "5.3.0",
    "html-loader": "0.5.5",
    "html-webpack-plugin": "3.2.0",
    "husky": "0.14.3",
    "jest": "22.4.3",
    "jest-junit": "5.1.0",
    "jest-preset-angular": "5.2.2",
    "jest-sonar-reporter": "2.0.0",
    "lint-staged": "7.0.0",
    "merge-jsons-webpack-plugin": "1.0.14",
    "moment-locales-webpack-plugin": "1.0.5",
    "prettier": "1.11.1",
    "proxy-middleware": "0.15.0",
    "raw-loader": "0.5.1",
    "rimraf": "2.6.1",
    "simple-progress-webpack-plugin": "1.1.2",
    "style-loader": "0.20.3",
    "tapable": "1.0.0",
    "terser-webpack-plugin": "1.0.0",
    "thread-loader": "1.1.5",
    "to-string-loader": "1.1.5",
    "ts-loader": "4.0.1",
    "tslint": "5.9.1",
    "tslint-config-prettier": "1.9.0",
    "tslint-loader": "3.6.0",
    "typescript": "2.7.2",
    "webpack": "4.8.0",
    "webpack-cli": "2.1.3",
    "webpack-dev-server": "3.1.5",
    "webpack-merge": "4.1.2",
    "webpack-notifier": "^1.15.0",
    "webpack-visualizer-plugin": "0.1.11",
    "workbox-webpack-plugin": "3.2.0",
    "write-file-webpack-plugin": "4.2.0",
    "xml2js": "0.4.19"
  },
  "engines": {
    "node": ">=8.9.0"
  },
  "lint-staged": {
    "src/**/*.{ts,css,scss}": [
      "prettier --write",
      "git add"
    ]
  },
  "scripts": {
    "precommit": "lint-staged",
    "prettier:format": "npm prettier --write 'src/**/*.{ts,css,scss}'",
    "lint": "tslint --project tsconfig.json -e 'node_modules/**'",
    "lint:fix": "npm run lint -- --fix",
    "ngc": "ngc -p tsconfig-aot.json",
    "cleanup": "rimraf target/{aot,www}",
    "clean-www": "rimraf target//www/app/{src,target/}",
    "start": "npm run webpack:dev",
    "serve": "npm run start",
    "build": "npm run webpack:prod",
    "test": "npm run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js",
    "test:watch": "npm test -- --watch --clearCache",
    "webpack:dev": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9060 --watch-content-base --env.stats=minimal",
    "webpack:dev-verbose": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9060 --watch-content-base --profile --progress --env.stats=normal",
    "webpack:build:main": "npm run webpack -- --config webpack/webpack.dev.js --env.stats=normal",
    "webpack:build": "npm run cleanup && npm run webpack:build:main",
    "webpack:prod:main": "npm run webpack -- --config webpack/webpack.prod.js --profile",
    "webpack:prod": "npm run cleanup && npm run webpack:prod:main && npm run clean-www",
    "webpack:test": "npm run test",
    "webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js"
  },
  "jestSonar": {
    "reportPath": "target/test-results/jest",
    "reportFile": "TESTS-results-sonar.xml"
  }

希望能帮上忙!

jrcvhitl

jrcvhitl1#

您的资源库告诉您它需要Angular 5才能运作,但您在项目中使用的是Angular 6。
您所要做的就是通过降级Angular 版本或升级库版本来调整版本要求。
如果你知道它无论如何都能工作,你可以运行带有-f标志的命令,这将强制安装你的库,而不检查兼容的版本。

相关问题