16

i ran ng new in terminal. I ended up getting an npm error

  1. new folder
  2. run ng new in new folder
  3. set the name and accept defaults (and use SCSS)
  4. watch it create files and error at the end
⠸ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: project-name@0.0.0
npm ERR! Found: jasmine-core@3.7.1
npm ERR! node_modules/jasmine-core
npm ERR!   dev jasmine-core@"~3.7.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.8" from karma-jasmine-html-reporter@1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR!   dev karma-jasmine-html-reporter@"^1.5.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/user/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2021-07-11T18_12_50_796Z-debug.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.
peterh
  • 11,875
  • 18
  • 85
  • 108
a1cd
  • 17,884
  • 4
  • 8
  • 28

2 Answers2

54

I had this same issue with a fresh project, etc.

In the generated package.json you should see a line that says "jasmine-core": "~3.7.0" but it seems that other dependencies (I believe karma based on the error output here) require jasmine-core at 3.8.0 or higher. Simply edit the line that says "jasmine-core": "~3.7.0", to be "jasmine-core": "~3.8.0", and then manually run npm install and it should succeed.

You should then be able to run ng serve --open from the same directory and have it run just fine.

Samuel Sampson
  • 656
  • 6
  • 3
3

I changed "jasmine-core": "~3.7.0", to "jasmine-core": "~3.8.0" in package.json.template, I can create projects with no issues now. The location may vary, mine is: /usr/local/lib/node_modules/@angular/cli/node_modules/@schematics/angular/workspace/files/package.json.template

This will fix the problem in new projects

jbacav
  • 31
  • 3
  • Welcome to stack**overflow**. What does this post add to [Samuel Sampson's answer](https://stackoverflow.com/a/68339952)? (Or [David Öztürk's](https://stackoverflow.com/a/67446215), at that.) – greybeard Jul 13 '21 at 07:49
  • Please correct the file name. It is package.json. Not package.json.template – Syed Nasir Abbas Jul 13 '21 at 22:00
  • 2
    jbacav is right, he's showing you how to edit the global template file that the cli uses when constructing the new projects. By altering it in the global template file any future angular project you generate via the CLI will have the jasmin-core set to the 3.8.0 version by default. – Agentwalker Aug 20 '21 at 16:22