首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Vue包依赖冲突,找到vue@2.6.14

Vue包依赖冲突,找到vue@2.6.14
EN

Stack Overflow用户
提问于 2022-06-20 19:34:18
回答 2查看 865关注 0票数 1

我正在继承一个项目,它是建立在Vue 2上的,我相信问题是我的系统上安装了Vue 3(我在macOS上)。

Vue是个新手,所以如果答案很明显,我很抱歉。

我的package.json。您可以在这里看到我的vue版本是2.6.10,我相信错误是说我已经在我的主机系统上安装了3.0,可能是全局安装的。我不知道如何绕过这一点,我需要Vue 3安装在我的系统上为另一个项目,我相信这是什么是冲突的。

代码语言:javascript
运行
复制
{
  "name": "test-vuetify",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "@fontsource/roboto": "^4.5.7",
    "axios": "^0.21.4",
    "core-js": "^2.6.5",
    "plotly.js": "^1.52.2",
    "plotly.js-cartesian-dist-min": "^1.54.5",
    "sinon": "^8.1.1",
    "socket.io-client": "^4.4.1",
    "vue": "^2.6.10",
    "vue-class-component": "^7.0.2",
    "vue-json-csv": "^1.2.12",
    "vue-moment": "^4.1.0",
    "vue-property-decorator": "^8.1.0",
    "vue-router": "^3.0.3",
    "vue-toast-notification": "^3.0.0",
    "vue-toasted": "^1.1.28",
    "vuetify": "^2.4.4",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@mdi/font": "^4.2.95",
    "@types/jest": "^24.0.19",
    "@vue/cli-plugin-babel": "^3.11.0",
    "@vue/cli-plugin-typescript": "^3.11.0",
    "@vue/cli-plugin-unit-jest": "^4.2.2",
    "@vue/cli-service": "^3.11.0",
    "@vue/test-utils": "1.0.0-beta.31",
    "canvas": "^2.9.0",
    "jest-canvas-mock": "^2.2.0",
    "sass": "^1.18.0",
    "sass-loader": "^7.1.0",
    "typescript": "^3.4.3",
    "vue-cli-plugin-vuetify": "^0.6.3",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.2.2"
  }
}

当我安装npm时的错误..。

代码语言:javascript
运行
复制
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: vue-toast-notification@3.0.0
npm ERR! Found: vue@2.6.14
npm ERR! node_modules/vue
npm ERR!   vue@"^2.6.10" from the root project
npm ERR!   peer vue@"2.x" from @vue/test-utils@1.0.0-beta.31
npm ERR!   node_modules/@vue/test-utils
npm ERR!     dev @vue/test-utils@"1.0.0-beta.31" from the root project
npm ERR!   7 more (vue-class-component, vue-jest, vue-json-csv, vue-moment, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.0" from vue-toast-notification@3.0.0
npm ERR! node_modules/vue-toast-notification
npm ERR!   vue-toast-notification@"^3.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: vue@3.2.37
npm ERR! node_modules/vue
npm ERR!   peer vue@"^3.0" from vue-toast-notification@3.0.0
npm ERR!   node_modules/vue-toast-notification
npm ERR!     vue-toast-notification@"^3.0.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.
EN

回答 2

Stack Overflow用户

发布于 2022-06-20 20:50:06

此错误源位于vue-toast-notification@3.0.0中。

代码语言:javascript
运行
复制
npm ERR! While resolving: vue-toast-notification@3.0.0

提到的问题是:

代码语言:javascript
运行
复制
npm ERR! Found: vue@2.6.14
…
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.0" from vue-toast-notification@3.0.0

这个错误意味着库vue-toast-notification@3.0.0需要版本3中的Vue才能正确工作(这里提到版本是对等依赖的,我也在他们的文档页上确认了这一点)。换句话说,您在项目中使用的是一个不兼容的库。您有Vue@2项目,其中您安装了一个专门用于Vue@3项目的依赖包。要解决这个问题,您需要将vue-toast-notification作为一个依赖项来安装,其版本专用于vue@2。在本例中,它应该是vue-toast-notification@^0.6

票数 0
EN

Stack Overflow用户

发布于 2022-09-29 18:38:11

  • 如果您在vue 3上,并且需要安装vue 2项目的节点模块,请使用遗留对等设备来安装vue 2项目节点模块的模块。
  • 也可以通过降低节点包管理器(Npm)的级别来实现这一点。 为了你 npm安装-遗留-对等设备 安装-g npm@6.14.8
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72692138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档