运行“vue升级”时出现“无法解决依赖关系”错误

zac*_*son 6 npm vue.js vuejs3

我正在尝试使用此处的说明来安装 Vue 3 的迁移版本。

当我到达它告诉您运行的点时,vue upgrade我选择y安装升级,然后它给我以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ed_editor@0.1.0
npm ERR! Found: vue@2.6.14
npm ERR! node_modules/vue
npm ERR!   vue@"^2.6.11" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"3.1.5" from @vue/compiler-sfc@3.1.5
npm ERR! node_modules/@vue/compiler-sfc
npm ERR!   peer @vue/compiler-sfc@"^3.0.0-beta.14" from @vue/cli-service@4.5.13
npm ERR!   node_modules/@vue/cli-service
npm ERR!     dev @vue/cli-service@"~4.5.13" 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 C:\Users\Zach\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Zach\AppData\Local\npm-cache\_logs\2021-08-08T22_29_19_955Z-debug.log
 ERROR  command failed: npm install --loglevel error @vue/cli-service@~4.5.13
Run Code Online (Sandbox Code Playgroud)

我已阅读错误消息,但不知道如何解决该问题。我尝试使用--force,但后来似乎只会引起更多问题。

我该如何解决这个问题?

Tro*_*ott 10

您可能使用 npm 版本 7。(使用 npm 版本 7,我能够根据您的错误消息复制您的错误。)最简单的解决方案是:

  • 使用npm--legacy-peer-deps标志
  • 使用版本 6(其中版本 7 的标志npm的行为是默认的)npm--legacy-peer-deps

本教程和包可能是使用npm版本 6(或者可能是 5 或 4)编写和测试的。许多现有项目ERESOLVE在版本 7 中都会遇到此错误npm,因为该版本开始将对等依赖关系问题视为错误,而不是可以忽略的建议问题。