Running svelte dev on server

时间秒杀一切 提交于 2021-01-05 11:29:19

问题


I am running svelte like this on my server:

$ npm run dev


  Your application is ready~! 🚀

  - Local:      http://localhost:5000

────────────────── LOGS ──────────────────

Which is great. However, when I try to access through my public ip, the bundle is not found. I.E. When I type <publicIP>:5000 into the browser. It doesn't show up. The port is open and accessible. Is there any way to achieve this?

The request just fails. But shouldn't it work if it's running on localhost:5000? I have set up a node server and I can indeed access it on port 5000, but it doesn't serve the files properly like npm run dev does.


回答1:


Declare the environment variable HOST=0.0.0.0

HOST=0.0.0.0 npm run dev

inspiration / possible source: https://github.com/lukeed/sirv/issues/29#issuecomment-497907602


You can also modify the dev script in the package.json and prepend HOST=0.0.0.0

  "scripts": {
    "build": "rollup -c",
    "dev": "HOST=0.0.0.0 rollup -c -w",
    "start": "sirv public"
  },

And now you can simply run npm run dev



来源:https://stackoverflow.com/questions/63255453/running-svelte-dev-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!