javascript - 在ubuntu上安装并运行browserquest

标签 javascript node.js httpserver

我已经安装了 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 服务器来托管客户端文件 http://search.npmjs.org/#/http-server

最佳答案

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

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

1) 从 github 存储库获取副本。

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

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

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

关于javascript - 在ubuntu上安装并运行browserquest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10238034/

相关文章:

python - Django和Node –如何运作?

node.js - 如何正确关闭 Node.js 服务器上的 MongoClient 连接?

node.js - 构建时出现 Nativescript 错误

node.js - Passport 本地策略没有被调用

javascript - 我们如何在 Java 中编写/自动化 firebug --> Profile JavaScript,以便它可以从浏览器外部运行?

javascript - Vuetify 网格系统行管理

http - 在 Apache Cassandra 中存储和显示图像文件

c++ - 登录 HTTP 服务器 c++

javascript - showModalDialog 已弃用 Chrome37,还有其他建议吗?

javascript - 如何在不丢失样式的情况下打印vue组件的一部分