How to run Vite dev server on network [Network: use ` --host` to expose]
May 6, 2022
Problem…
You are using Vite in your front end development project and trying to open your localhost website or web app on a different device on your network but it doesn’t seem to work.
You checked your running server and this is what you have:
Voila! You simply do npm run dev --host
but nothing happens.
Solution…
- The first solution is to add two hyphens and a space before
--host
like this:
npm run dev -- --host
2. If you go with the first solution you’ll always have to type that so an even better solution is to add --host
to the dev script in package.json