How to run Vite dev server on network [Network: use ` --host` to expose]

--

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:

vite dev server running

Voila! You simply do npm run dev --host but nothing happens.

Solution…

  1. 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

--

--

Samuel Darkwah Manu
Samuel Darkwah Manu

Written by Samuel Darkwah Manu

GIS | Data Visualisation | Frontend Development

No responses yet