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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:22:10  来源:igfitidea点击:

Angular.js Tutorial using the Node.js webserver

javascriptgitnode.jsangularjs

提问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?

有没有人完成本教程或知道如何正确使用此步骤来使服务器正常工作?

  1. For node.js users: In a separate terminal tab or window, run node scripts\web-server.jsto start the web server. Open a browser window
  2. for the app and navigate to http://localhost:8000/app/index.html
  1. 对于 node.js 用户:在单独的终端选项卡或窗口中,运行node scripts\web-server.js以启动 Web 服务器。打开浏览器窗口
  2. 对于应用程序并导航到 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.jsis 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 中运行它。