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

thebigk's avatar
Level 13

npm run build works, but npm run dev doesn't

I've recently created a new project and using VITE for the first time. I'm running into a strange problem -

npm run build works fine and create proper asset urls. However, if I run npm run dev, I get following asset url

https://localhost:3000/@vite/client

Which doesn't work. I'm guessing some configuration related issue. Posting my vite configuration below -

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/app.css',
            'resources/js/app.js',
        ]),
    ],
    server: {
        https: true,
        host: 'localhost',
    },
});

Would appreciate some help in identifying the issue. Thank you in advance!

0 likes
3 replies
Keshi's avatar
Keshi
Best Answer
Level 1

What if you removed the last line in your vite config file ie server: { https: true, host: 'localhost', }, You remove this part of the code and see if it works

1 like
thebigk's avatar
Level 13

@Keshi Oh yeah, it works! I simply followed the instructions in documentation. I use 'https' on my local dev machine, using Valet.

So, can I completely skip -

server: {
        https: true,
        host: 'localhost',
    },

?

Keshi's avatar

Yes, you can skip since the project is running in your local machine using the npm run dev command

Please or to participate in this conversation.