git 使用 Node.js 网络服务器的 Angular.js 教程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15658899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Angular.js Tutorial using the Node.js webserver
提问by ojhawkins
I am trying to go through the Angular.js Tutrorial_00and cannot seem to work out how to get the node.js web server to run the demo app?
我正在尝试浏览Angular.js Tutrorial_00,但似乎无法弄清楚如何让 node.js Web 服务器运行演示应用程序?
Has anyone done this tutorial or know how correctly use this step to get the server working?
有没有人完成本教程或知道如何正确使用此步骤来使服务器正常工作?
- For node.js users: In a separate terminal tab or window, run
node scripts\web-server.js
to start the web server. Open a browser window - for the app and navigate to
http://localhost:8000/app/index.html
- 对于 node.js 用户:在单独的终端选项卡或窗口中,运行
node scripts\web-server.js
以启动 Web 服务器。打开浏览器窗口 - 对于应用程序并导航到
http://localhost:8000/app/index.html
What happens is that I run step 1 in node.js and then it outputs "...", which I assum means it is listening.
发生的情况是我在 node.js 中运行第 1 步,然后它输出“...”,我认为这意味着它正在侦听。
Then when I get to step 2 I type that in the browser and get "Oops! Google Chrome could not connect to ".
然后当我进入第 2 步时,我在浏览器中输入它并得到“糟糕!谷歌浏览器无法连接到”。
回答by Quentin
node scripts\web-server.js
is a command line, not a piece of JavaScript.
node scripts\web-server.js
是一个命令行,而不是一段 JavaScript。
Run it in a shell (on Windows that probably means PowerShell) while making sure you are in the right directory. Don't try to run it in a node REPL.
在 shell 中运行它(在 Windows 上可能意味着 PowerShell),同时确保您位于正确的目录中。不要尝试在节点 REPL 中运行它。