1、原因
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: admin@0.1.0
npm ERR! Found: eslint@7.32.0
npm ERR! node_modules/eslint
npm ERR! dev eslint@"^7.32.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">= 1.6.0 < 7.0.0" from @vue/cli-plugin-eslint@4.5.19
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR! dev @vue/cli-plugin-eslint@"~4.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中,默認情況下,npm install遇到沖突的peerDependencies時將失敗。
2、解決
使用–force或–legacy-peer-deps可解決這種情況。
–force 會無視沖突,并強制獲取遠端npm庫資源,當有資源沖突時覆蓋掉原先的版本。
–legacy-peer-deps:安裝時忽略所有peerDependencies,忽視依賴沖突,采用npm版本4到版本6的樣式去安裝依賴,已有的依賴不會覆蓋。
建議用–legacy-peer-deps 比較保險一點
npm install --legacy-peer-deps