Laravel mix vite function not defined
- Published
- Reading time
- 1 min read
- Length
- 213 words
On this page
Laravel mix vite function not defined#
If you are facing the issue of "vite function not defined" while using Laravel mix, then it means that there is some issue with the vite package that Laravel mix is trying to use.
This issue can be resolved by following the below steps:
Step 1: Update Laravel Mix version#
Make sure you are using the latest version of Laravel Mix. You can update it by running the below command in your terminal:
npm update laravel-mixStep 2: Install Latest Version of Vite#
Install the latest version of Vite package by running the below command in your terminal:
npm install vite@latest --save-devStep 3: Update Laravel Mix Configuration#
Update the Laravel Mix configuration by adding the below code to your webpack.mix.js file:
mix.config.webpackConfig.resolve.alias = {
'@': path.resolve('resources/js'),
'vue$': 'vue/dist/vue.esm.js',
'vite$': 'vite/dist/node/index.js'
};This code will add aliases for @ and vite to your webpack configuration.
If the above steps do not resolve your issue, then you can try removing the node_modules folder and reinstalling all the packages by running the below commands:
rm -rf node_modules
npm installAfter following these steps, you should not face any issues with the "vite function not defined" error.