【问题标题】:Node http-server not working on Ubuntu linux节点 http-server 在 Ubuntu linux 上不起作用
【发布时间】: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 打开浏览器时 - 它无法连接到主机。

我错过了什么吗?

【问题讨论】:

标签: node.js http npm httpserver


【解决方案1】:

好的,问题是 - 我在 Ubuntu 上安装了另一个软件包,也称为 node

Node JS 包在我的系统上被称为 nodejs,我认为 http-server 正在专门寻找“节点”。 为了解决这个问题:

我用sudo apt-get remove node 删除了 node 包,并为 nodejs 创建了一个符号链接:

sudo ln -s /usr/bin/nodejs /usr/local/bin/node

【讨论】:

    【解决方案2】:

    首先安装 npm。 第二个 npm install http-server -g。下一个附加在 http-server url 模板 url 之后,例如 http-server C:\xampp\htdocs\

    【讨论】:

    • Ubuntu 中的 C 盘?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-15
    相关资源
    最近更新 更多