Question

npm run dev --host network: not exposed

I want to expose my svelte app on LAN using the npm run dev --host command but it shows:

> frontend@0.0.1 dev
> svelte-kit dev


  SvelteKit v1.0.0-next.295

  local:   http://localhost:3000
  network: not exposed

  Use --host to expose server to other devices on this network


 46  80367  46
1 Jan 1970

Solution

 115

You have to add -- before the actual flag:

npm run dev -- --host

And it should output:

> project@0.0.1 dev
> svelte-kit dev "--host"


  SvelteKit v1.0.0-next.316

  local:   http://localhost:3000
  network: http://***.***.**.**:3000

  Note that all files in the following directories will be accessible to anyone on your network: src/lib, src/routes, .svelte-kit, src, node_modules
2022-04-20

Solution

 115

You have to add -- before the actual flag:

npm run dev -- --host

And it should output:

> project@0.0.1 dev
> svelte-kit dev "--host"


  SvelteKit v1.0.0-next.316

  local:   http://localhost:3000
  network: http://***.***.**.**:3000

  Note that all files in the following directories will be accessible to anyone on your network: src/lib, src/routes, .svelte-kit, src, node_modules
2022-04-20

Solution

 13

If you use vite in the package.json file, do this on the dev line:

  "scripts": {
    "dev": "vite --host --port 8888",
   .....  what ever else was here.....
  },

if you use sirv, try this in the package.json :

    "start": "sirv public --no-clear --host 0.0.0.0",

If you want a different port try this:

    "start": "sirv public --no-clear --host 0.0.0.0 --port 8888",
2022-07-08

Solution

 13

If you use vite in the package.json file, do this on the dev line:

  "scripts": {
    "dev": "vite --host --port 8888",
   .....  what ever else was here.....
  },

if you use sirv, try this in the package.json :

    "start": "sirv public --no-clear --host 0.0.0.0",

If you want a different port try this:

    "start": "sirv public --no-clear --host 0.0.0.0 --port 8888",
2022-07-08