Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
868 views
in Technique[技术] by (71.8m points)

web - unable to resolve dependency tree error for creating new angular project

so today I wanted to create a new Angular project using the command ng new <projectname> and I got this error:

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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 [email protected]
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.

I literally tried everything, I updated npm, installed Angular cli again, download and installed node again, npm audit, and a lot of other things but nothing happened.

Also as you can see error told me to use the command with --force, I tried but nothing happened, and with --legacy-peer-deps, I get the error as unknown option.

What is bothering me the most is that everything was working completely right last night and I changed nothing at all but suddenly I'm getting this error today.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Open the folder you create with ng new and open the package.json file. In devDependencies change the version of "jasmine-core" 3.6.0 to 3.8.0 and "karma-jasmine-html-reporter" from 1.7.0 to 1.6.0 and save it. Then go back to Terminal and go to your project and run npm install. Now it works and you can run ng serve.

Edit 2021

"jasmine-core": "~3.8.0",
"karma-jasmine-html-reporter": "^1.7.0"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...