vite: not found Error in Laravel 11
Last update: 06-02-2024
As a new Laravel developer, you might run into various issues while setting up your development environment. One such issue that I encountered recently involved an error with Vite while using Laravel Breeze for authentication. Here's a quick tip that might save you some troubleshooting time.
The Problem:
After cloning my Laravel 11 repository and setting up the environment, I tried to build the assets by running the following command:
npm run build
However, I was greeted with the following error message:
> build
> vite build
sh: 1: vite: not found
The Solution:
The error message indicated that the vite
command was not found. This typically happens when the npm packages are not installed. To resolve this, you need to install the npm dependencies by running:
npm install
After running this command, the required packages will be installed, and you should be able to successfully build your assets with:
npm run build
Conclusion:
This small oversight of forgetting to install npm dependencies can be a common pitfall, especially when you're in the middle of setting up your development environment or cloning a new repository. Remembering to run npm install
can save you from such errors and keep your workflow smooth.
Happy coding!