error when creating a new angular project after updating the cli version

Viewed 911

I had angular cli 6.* installed in my mac and I wanted to update this version to 8.* after doing this the ng new app return an error.

Terminal :

...
CREATE timelines/e2e/src/app.po.ts (251 bytes)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: timelines@0.0.0
npm ERR! Found: jasmine-core@3.4.0
npm ERR! node_modules/jasmine-core
npm ERR!   dev jasmine-core@"~3.4.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.5" from karma-jasmine-html-reporter@1.5.4
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR!   dev karma-jasmine-html-reporter@"^1.4.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/tarek/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tarek/.npm/_logs/2021-04-30T10_18_04_291Z-debug.log
Package install failed, see above.

I tried to delete everything related to Angular, npm, angular cli etc... and re install them but errors still persist

package.json file :

{
  "name": "timelines",
  "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": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.802.2",
    "@angular/cli": "~8.2.2",
    "@angular/compiler-cli": "~8.2.0",
    "@angular/language-service": "~8.2.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }
}

I could not create projects any more please help

3 Answers

Workaround: Create a project with ng new my-app --skip-install, go to the app directory, remove all jasmine dependencies from package.json and run npm install. You won't be able to run npm test, but the project will build and run

Maybe your Node version is incompatible. Try to update Node to the latest stable version, then install @angular/cli globally, and then try to create a new Angular project.

May be following steps would work:

npm uninstall -g @angular/cli
npm install -g @angular/cli

OR

npm cache clean --force    
npm install
Related