0

I'm having the next error when running npm i command:

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

I tried to remove the node_modules directory and re-running npm i, but it didn't work. I also tried to reinstall NodeJS, but it didn't solve this error.

I have no idea about what is happening. This command has always worked like a charm.

Here's my package.json:

"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"
  }

I hope it helps!

spovmon
  • 17
  • 2
  • Does this answer your question? [Could not resolve peer dependency between my Angular app and my custom Angular library](https://stackoverflow.com/questions/71066810/could-not-resolve-peer-dependency-between-my-angular-app-and-my-custom-angular-l) – Vimal Patel Nov 18 '22 at 13:59
  • @spovmon try this `npm install --legacy-peer-deps` – Adem kriouane Nov 18 '22 at 14:02
  • you can check this question [Unable to resolve dependency tree error when installing npm packages](https://stackoverflow.com/questions/64573177/unable-to-resolve-dependency-tree-error-when-installing-npm-packages) – Adem kriouane Nov 18 '22 at 14:06

1 Answers1

0

Your library is telling you that it needs angular 5 to work, but you're using angular 6 in your project.

All you have to do is align the version requirements, by either downgrading your angular version, or upgrading your library version.

If you KNOW it will work anyways, you can run your command with the -f flag, that will force the installation of your library without checking for compatible versions.

MGX
  • 2,534
  • 2
  • 14