Laravel mix vite function not defined

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-mix

Step 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-dev

Step 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 install

After following these steps, you should not face any issues with the "vite function not defined" error.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe