【发布时间】:2014-09-13 12:15:46
【问题描述】:
我正在尝试在我的项目目录中运行一个简单的 http 服务器。我需要的只是 GET 请求支持,所以我可以 GET html/css/js/etc。 为此,我想使用来自 npm 的 http-server。
我用npm install http-server -g安装了它
现在我 cd 到我的项目文件夹,其中有 index.html 文件,我打开终端并运行 http-server
但是当我在 http://localhost:8080/index.html 打开浏览器时 - 它无法连接到主机。
我错过了什么吗?
【问题讨论】:
-
来自 npm:在本地启动 http-server
node bin/http-server。现在您可以访问localhost:8080 来查看您的服务器。 npmjs.org/package/http-server(“使用”)。 -
相同的结果 - 无法连接。它会在任何地方存储日志吗?
-
REPL中有输出吗? nodejs.org/api/repl.html -
奇怪的是,它适用于我的 Windows,但不适用于 linux (Mint 17)
-
酷。 REPL 基本上是 V8 的控制台,docs.nodejitsu.com/articles/REPL/how-to-use-nodejs-repl。
标签: node.js http npm httpserver