【问题标题】:Installing and running browserquest on ubuntu在 ubuntu 上安装和运行 browserquest
【发布时间】:2012-04-28 05:02:42
【问题描述】:

我已经安装了 node.js 和必要的包来运行browserquest。我已经启动了 browserquest 服务器,它在端口 8080 上运行,当我进入浏览器并输入 http://localhost:8080/status 时,我可以看到服务器正在运行,并且当前没有连接任何客户端。我在 client/config/build_config.json 文件中使用这样的配置构建客户端

{
   "host": "http://127.0.0.1",
   "port": 8080
}

我在 bin/build.sh 中构建我的客户端。然后我运行这个命令来创建 http-server 来服务客户端文件。

http-server path-to-client-build -p 8000

我可以通过转到http://localhost:8000/index.html 看到正在运行 httpserver 的索引页面,但是当我尝试连接时,它在说连接到服务器后卡住了。

注意:我正在使用这个 http-server 来托管客户端文件 http://search.npmjs.org/#/http-server

【问题讨论】:

    标签: javascript node.js httpserver


    【解决方案1】:

    我认为客户端构建在 github 上的当前版本上存在一些问题。相反,我使用了实际的客户端文件夹。我已按照这些步骤使其工作。

    确保你已经安装了 node 和 npm。

    1) 从 github repo 获取一份副本。

    git clone https://github.com/mozilla/BrowserQuest.git
    

    2) 为服务器安装所需的节点包

    npm install underscore log bison websocket websocket-server sanitizer memcache
    

    3) 启动服务器

    node server/js/main.js
    

    4) 转到客户端目录并安装 http-server 模块以服务客户端文件

    cd client
    npm install -g http-server
    

    5) 编辑 config_build.json-dist 以指向您的主机 IP 和端口(在我的情况下为 127.0.0.1 localhost)

    {
    "host": "127.0.0.1",
    "port": 8000,
    "dispatcher": false
    }
    

    6) 将编辑后的 ​​config_build.json-dist 复制到 2 个新文件中

    cp config_build.json-dist config_build.json
    cp config_build.json-dist config_local.json
    

    7) 将共享文件夹复制到客户端文件夹中

    cp -r ../shared .
    

    8) 启动 http-server 服务客户端文件

    http-server
    

    您的服务器和客户端应该正在运行。您可以通过转到http://ipaddress:port/status 来检查服务器是否正在运行,这应该会显示一系列已连接的客户端。如果没有空数组。你的客户端应该在http://ipaddress:8000/index.html上运行

    基于 dirkk0 的教程 https://gist.github.com/2275361

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-13
    相关资源
    最近更新 更多