http-server 为什么要这样做?

Why is this http-server doing this?

我是 Node 新手,我正在尝试 运行 本地服务器。

我遵循了这个简单的步骤:Setup a simple Node server

我移动到我有 index.html 文件的文件夹:

我 运行 http-server 然后我浏览到 http://localhost:8080/ 这就是我得到的:

我不知道我做错了什么。

这个也让我抓狂了几次 - if you have a ./public folder, the http-server library defaults to serving that rather than ./. 在我看来有点愚蠢的默认设置,但是哦好吧!

您可以通过在启动服务器时明确说明路径来解决此问题:

http-server ./