Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting errors while trying to do npm install on package.json

I'm trying to do npm install for setting up an Angular project, but am running into these errors. I am on mac and trying to open up a relatively old project, which is most likely the reason I'm running into the issues that I'm having.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @angular-devkit/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"~3.5.3" from the root project
npm ERR!   peer typescript@">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev" from [email protected]
npm ERR!   node_modules/tslint
npm ERR!     dev tslint@"~5.15.0" from the root project
npm ERR!   1 more (tsutils)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=4.8.2 <5.0" from @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"^15.2.2" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/typescript
npm ERR!   peer typescript@">=4.8.2 <5.0" from @angular-devkit/[email protected]
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"^15.2.2" 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.

I tried doing --force and --legacy-peer-deps but they both give me several vulnerabilities. I also tried playing around downgrading node versions but to no avail. I looked in the package.json version and located "@types/node": "~8.9.4", and from my what I've found is a specified dependency for the project, and tried downgrading to that version. All that did was make it incredibly slow and eventually left me with errors. Here is the package.json file:

{
  "name": "client",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.2.2",
    "@angular/cdk": "^15.2.2",
    "@angular/common": "^15.2.2",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/flex-layout": "^8.0.0-beta.27",
    "@angular/forms": "^15.2.2",
    "@angular/material": "^15.2.2",
    "@angular/platform-browser": "^15.2.2",
    "@angular/platform-browser-dynamic": "^15.2.2",
    "@angular/router": "^15.2.2",
    "apollo-angular": "^4.2.1",
    "apollo-angular-link-http": "^1.11.0",
    "apollo-cache-inmemory": "^1.6.6",
    "apollo-client": "^2.6.10",
    "apollo-link": "^1.2.14",
    "deep-copy-ts": "^0.5.0",
    "graphql": "^14.7.0",
    "graphql-tag": "^2.11.0",
    "hammerjs": "^2.0.8",
    "rxjs": "~6.4.0",
    "ts-deepcopy": "^0.1.4",
    "tslib": "^1.13.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.2",
    "@angular/cli": "^15.2.2",
    "@angular/compiler-cli": "^15.2.2",
    "@angular/language-service": "^8.2.14",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "~8.9.4",
    "codelyzer": "^0.0.28",
    "jasmine-core": "^3.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^6.4.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "protractor": "^7.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }
}

angular-cli version

Here are the versions when i run `ng version' in my terminal. I've just started working with front-end development so some input would be appreciated.

Edit: Did robert's suggestion, got following error.

Attempt 2 enter image description here enter image description here

like image 699
visiontech60 Avatar asked Oct 28 '25 04:10

visiontech60


1 Answers

This Problem is due to Having an Angular Version but not all npm packages are in support to the current version and many other deprecated functionalities.

npm install --force 

It will download all the packages with their versions from package.json and make sures it will run the project when using

npm run start

To only download specified versions packages

npm ci --force

To fix the issue once you installed all the packaage.json if any problem arsies then use

npm install --legacy-peer-deps
like image 50
melenchenkov Avatar answered Oct 29 '25 20:10

melenchenkov