Node js as http server and host angularJS SPA

dhana picture dhana · Jul 17, 2015 · Viewed 17.2k times · Source

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

Answer

Anand picture Anand · Jul 17, 2015
  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