简体   繁体   中英

ERESOLVE unable to resolve dependency tree?

When you try to create an angular project via the angular cli, you get this error

    npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: animation@0.0.0
npm ERR! Found: jasmine-core@3.6.0
npm ERR! node_modules/jasmine-core
npm ERR!   dev jasmine-core@"~3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.7.1" from karma-jasmine-html-reporter@1.6.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.

please help me, I don't understand what needs to be done here

Update (Angular 12.0.0)

Just a few hours after my answer, Angular 12 was released - which works perfectly with NPM 7.13.0 .

Original answer (Angular 11.2.11)

Which NPM version are you using?

I just faced the same problem using version 7.10.0 . After downgrading to 6.14.13 , ng new worked as expected.

npm i -g npm@6.14.13

Currently, this seems to be the best solution if you want to create an Angular project. However, the respective Issue on GitHub has already been closed. So I expect the next Angular release to also work with the latest NPM version.

I hope I could help you.

Although downgrading to an older version of npm works, I would not recommend that because they updated it for a reason.

The new version can have included critical patches to security holes, or they can have included new or enhanced features.

So, here is my solution:
Notice what angular says:

npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.7.1" from karma-jasmine-html-reporter@1.6.0

So, you need to open your package.json file and change jasmine-core version from 3.6.0 to 3.7.1 which is the version that angular angular found in karma-jasmine-html-reporter@1.6.0 .

Then delete the package-lock.json file and run npm install .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM