这个错误提示是由于在使用 Vite 构建工具时,缺少了 Vue 3.2.13 或 @vue/compiler-sfc 的依赖所导致的。解决方法如下:

  1. 确认项目中是否已经安装 Vue 3.2.13 或 @vue/compiler-sfc。如果没有安装,可以使用如下命令进行安装:

    npm install vue@3.2.13 -S  # 安装 Vue 3.2.13
    npm install @vue/compiler-sfc -D  # 安装 @vue/compiler-sfc
    
  2. 如果已经安装了依赖,但仍然出现这个错误,可以尝试删掉 node_modules 目录和 package-lock.json 文件,然后重新安装依赖:

    rm -rf node_modules
    rm package-lock.json
    npm install
    
  3. 如果以上方法都没有解决问题,可以尝试升级 Vite 版本:

    npm install vite@latest -g  # 全局安装最新版 Vite
    npm install vite@latest -D  # 在项目中安装最新版 Vite
    

    如果升级后仍然出现错误,可以尝试降低 Vite 版本

INFO Starting development server ERROR Error vitejsplugin-vue requires vue =3213 or vuecompiler-sfc to be present in the dependency treeError vitejsplugin-vue requires vue =3213 or vuecompiler-sfc t

原文地址: https://www.cveoy.top/t/topic/hhGB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录