我按照Yeoman 的指南设置了一个 Angular.js 应用程序。 除了将主机名从“localhost”更改为“0.0.0.0”外,我没有更改任何内容。
当我这样做时grunt serve
,没有错误。最终,我确实看到了“'Allo,'Allo”首页,但只是在livereload.js?snipver=1 延迟超过 30 秒之后,它未能 GET。正如你在右边看到的,服务器没有输出任何异常。
我的整个项目都在 github 上。
我对 livereload 进行了 grep-ped,发现了一些嫌疑人:
/node_modules/grunt-contrib-connect/node_modules/connect-livereload/index.js
下面有这两个函数,包含 livereload url。第一个链接到“ http://my.ip.addr.ess:9000/livereload.js ”,它有一个“Cannot GET”。function getSnippet() { /*jshint quotmark:false */ var snippet = [ "<!-- livereload script -->", "<script type=\"text/javascript\">document.write('<script src=\"http://'", " + (location.host || 'localhost').split(':')[0]", " + ':" + port + "/livereload.js?snipver=1\" type=\"text/javascript\"><\\/ script>')", "</script>", "" ].join('\n'); return snippet; }; function snippetExists(body) { if (!body) return true; return (~body.lastIndexOf("/livereload.js?snipver=1")); }
我的Gruntfile.js将 livereload 设置为 true,我想保留它。
有人有线索吗?
更新:
我又试了一次全新的机器,从头开始。我仍然遇到同样的问题!这次 livereload 的状态显示“net::ERR_CONNECTION_TIMED_OUT”。
更多信息:我在 AWS EC2 上运行,只打开了 8000 和 9000 端口。