Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KodaC's avatar
Level 1

npm run dev: Allways start VITE

Whenever I start npm run dev on a local web server with Laravel 10, VITE is started and the console does not go on.

How can I prevent vite from starting and still be able to use my local web server?

Can I only prevent this by using npm run build?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

To prevent VITE from starting when running npm run dev, you can modify the package.json file and remove the vite command from the dev script. Here's an example:

"scripts": {
    "dev": "php artisan serve",
    "watch": "npm run development -- --watch",
    "development": "mix",
    "production": "mix --production"
},

In this example, the dev script runs the Laravel server using php artisan serve, without starting VITE. You can still use your local web server by accessing it at the specified URL (usually http://localhost:8000).

If you need to use VITE for development, you can create a separate script that starts VITE and your local web server at the same time. Here's an example:

"scripts": {
    "dev": "php artisan serve",
    "watch": "npm run development -- --watch",
    "development": "mix",
    "production": "mix --production",
    "dev-vite": "npm run dev & vite"
},

In this example, the dev-vite script starts both the Laravel server and VITE using the & operator to run them in parallel. You can then access your local web server at the specified URL and use VITE for development at the same time by running npm run dev-vite.

1 like

Please or to participate in this conversation.