简体   繁体   English

在Node.js中部署angularjs应用程序

[英]Deploy angularjs application in Node.js

Hello I am following this tutorial from the AngularJS documentation. 您好我从AngularJS文档中学习本教程

I am trying to use this approach for learning this. 我试图用这种方法来学习这个。

You will need an http server running on your system. 您需要在系统上运行http服务器。 Mac and Linux machines typically have Apache pre-installed, but If you don't already have one installed, you can use node to run scripts/web-server.js, a simple bundled http server. Mac和Linux机器通常预先安装了Apache,但如果您还没有安装Apache,则可以使用node运行scripts / web-server.js,这是一个简单的捆绑式http服务器。

My server is started but the only things that happens on localhost:8000 (the port its running on) is that files get listed. 我的服务器已启动,但localhost:8000(其运行的端口)上发生的唯一事情就是列出了文件。

How do I deploy with Node.js? 如何使用Node.js进行部署?

When I navigate to localhost:8000 in my browser, this is my server log. 当我在浏览器中导航到localhost:8000时,这是我的服务器日志。

112-108-15:scripts phe$ ./web-server.js 112-108-15:脚本为$ ./web-server.js
Http Server running at http://localhost:8000/ Http Server运行在http:// localhost:8000 /
GET / Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36 GET / Mozilla / 5.0(Macintosh; Intel Mac OS X 10_8_4)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 29.0.1547.65 Safari / 537.36
GET / Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36 GET / Mozilla / 5.0(Macintosh; Intel Mac OS X 10_8_4)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 29.0.1547.65 Safari / 537.36

As you can see the instruction , you need to run 正如你所看到的指令 ,你需要运行

node ./scripts/web-server.js

and go to http://localhost:8000/app/index.html . 并转到http://localhost:8000/app/index.html

If you have node installed, go to the directory where your angular application is and type: 如果已安装节点,请转到角度应用程序所在的目录并键入:

scripts/webserver.js

hit enter and voila! 打进去瞧!

You can visit your site at: 您可以访问您的网站:

http://localhost:8000/

If you don't have node installed, install node and then go to the first step. 如果未安装节点,请安装节点,然后转到第一步。

You need to serve the files from a server on your local machine. 您需要从本地计算机上的服务器提供文件。

In the docs, it is mentioned you can serve the files from a node server. 在文档中,提到您可以从节点服务器提供文件。

However, if you do not want to download and run nodejs, and you are on Mac/Linux you have python already installed, you can also cd into the directory with index.html and run a python server - python -m SimpleHTTPServer 8000 . 但是,如果你不想下载和运行的NodeJS,你是在Mac / Linux的你已经安装Python,你也可以cd与目录中index.html和运行Python服务器- python -m SimpleHTTPServer 8000 This will serve the files on port 8000. Go to localhost:8000 and you will see your files being rendered. 这将为端口8000上的文件提供服务。转到localhost:8000,您将看到正在呈现的文件。

And, if you want to deploy it to production on a remote machine, I came across deployment of nodejs & angular application deployment to production using ansible. 而且,如果您希望将其部署到远程计算机上的生产中,我会使用ansible将nodejs和angular应用程序部署部署到生产中。 I used the same to deploy my first app to production. 我用同样的方法将我的第一个应用程序部署到生产中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM