Error: @vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc to be present in the dependency tree.

Error: @vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc to be present in the dependency tree.

This error occurs when you are using the Vite build tool with the Vite Vue plugin but don’t have the required version of Vue or the @vue/compiler-sfc module in your project’s dependencies.

Possible Solutions:

  1. Installing Vue:
  2. To fix this error, you need to ensure that you have Vue installed in your project. You can do this by running the following command in your project directory:

    npm install vue
  3. Upgrading Vue version:
  4. If you already have Vue installed but it is of a lower version than 3.2.13, you need to update it. You can use the following command to upgrade Vue:

    npm install vue@^3
  5. Installing @vue/compiler-sfc module:
  6. In case you don’t want to upgrade Vue, you can install the @vue/compiler-sfc module instead. This module provides the necessary functionality for the Vite Vue plugin. Use the following command to install it:

    npm install @vue/compiler-sfc
  7. Checking dependencies:
  8. If you have followed the above steps and are still facing the error, make sure to check your project’s dependencies in the package.json file. Ensure that vue and @vue/compiler-sfc are listed as dependencies.

Similar post

Leave a comment