在Vue 3.0应用程序中安装vue-apollo时版本不匹配

问题描述

我使用设置了新的Vue 3.0应用程序

vue create

然后我使用

将阿波罗添加到我的应用程序中
vue add apollo

然后,当我运行npm run build时,出现以下错误

ERROR  Failed to compile with 2 errors                                                                                                    

Module Error (from ./node_modules/vue-loader/lib/index.js):


Vue packages version mismatch:

- vue@3.0.0 (C:\workspace\StatusTool\dummy-project\node_modules\vue\index.js)
- vue-template-compiler@2.6.12 (C:\workspace\StatusTool\dummy-project\node_modules\vue-template-compiler\package.json)

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0,simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify,re-installing vue-loader/vueify should bump vue-template-compiler to the latest.


Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
    at parse (C:\workspace\StatusTool\dummy-project\node_modules\@vue\component-compiler-utils\dist\parse.js:15:23)
    at Object.module.exports (C:\workspace\StatusTool\dummy-project\node_modules\vue-loader\lib\index.js:67:22)

我在做什么错了?

版本信息:

  • @ vue / cli:4.5.6
  • vue-cli-plugin-apollo:“ 0.22.2”
  • 阿波罗:2.31.0

似乎未安装软件包vue-apollo

解决方法

请勿使用vue/cli: 4.5.6,而需要使用Manual install

vue add apollo仅适用于vue-cli 3个项目。

安装简单。

npm install --save vue-apollo graphql apollo-boost

yarn add vue-apollo graphql apollo-boost

您仍然可以使用apollo-boost

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...