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:
- Installing Vue:
- Upgrading Vue version:
- Installing @vue/compiler-sfc module:
- Checking dependencies:
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
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
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
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.