在ubuntu上安装并运行browserquest

时间:2012-04-19 22:58:31

标签: javascript node.js httpserver

我已经安装了node.js和必要的软件包来运行browserquest。我已经启动了在端口8080上运行的browserquest服务器,当我进入浏览器并输入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

1 个答案:

答案 0 :(得分:6)

我认为客户端构建在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

相关问题