我已经安装了 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/