节点js为http服务器和主机angularJS SPA [英] Node js as http server and host angularJS SPA

查看:98
本文介绍了节点js为http服务器和主机angularJS SPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序写在angularJS上,并由grunt构建。有没有一种方法可以从节点js创建一个http服务器并将其托管在那里。请分享任何有助于解决问题的代码段或文档。谢谢 如果您没有任何服务器端逻辑,你可以简单地通过npm的http-server模块为客户端提供AngularJS / HTML / css服务。
https://www.npmjs.com/package/http-server
只需通过
$> npm install -g http-server
安装它,然后转到您的客户端文件夹,输入http-server并按回车。


  • 如果您编写了服务器端代码(ExpressJS或restify web api),则使用$> nodemon server.js

  • 如果您正在查看选项对于生产应用,永远考虑/ pm2
    https://www.npmjs.com/package/pm2
    https://www.npmjs.com/package/forever



    I have an application written on angularJS and built by grunt. Is there a way I can create a http server from node js and host it there. Please share any code snippet or document which would help. Thanks

    解决方案

    1. (simplest) if you don't have any server side logic, you can simply serve client side AngularJS/HTML/css via http-server module from npm. https://www.npmjs.com/package/http-server Just install it via $>npm install -g http-server and go to your client folder, type http-server and hit enter.

    2. If you have server side code written, (ExpressJS or restify web api) then use $>nodemon server.js

    3. If you are looking at options for production applications, consider forever/pm2 https://www.npmjs.com/package/pm2 https://www.npmjs.com/package/forever

    这篇关于节点js为http服务器和主机angularJS SPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆