报错:Error: @vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc to be present in the depen
warning:
这篇文章距离上次修改已过203天,其中的内容可能已经有所变动。
解释:
这个错误表明你正在使用的 @vitejs/plugin-vue
插件需要 vue
版本至少为 3.2.13 或者 @vue/compiler-sfc
来进行项目构建。如果你的项目中安装的 vue
版本低于 3.2.13,或者没有安装 @vue/compiler-sfc
,你会遇到这个错误。
解决方法:
确认你的
vue
版本至少为 3.2.13。可以通过在项目根目录运行以下命令来更新vue
:npm install vue@latest
或者如果你使用
yarn
:yarn add vue@latest
如果你已经有了正确的
vue
版本,确保安装了@vue/compiler-sfc
。可以通过以下命令安装:npm install @vue/compiler-sfc
或者如果你使用
yarn
:yarn add @vue/compiler-sfc
确保你的
package.json
文件中的依赖版本符合要求,然后重新安装所有依赖:npm install
或者如果你使用
yarn
:yarn install
- 如果问题依旧存在,尝试删除
node_modules
文件夹和package-lock.json
或yarn.lock
文件,然后重新安装依赖。 - 确保你的 Vite 配置文件(如果有的话)正确配置了插件和依赖。
如果在更新或安装依赖后问题仍未解决,可能需要检查 Vite 配置文件或者 vite.config.js
中是否有相关配置错误。
评论已关闭