How to run AngularJS2 application without Node server How to run AngularJS2 application without Node server ruby-on-rails ruby-on-rails

How to run AngularJS2 application without Node server


I think you're mixing up some technologies here.

Server

You can run an Angular app on any server that can host static files. There is nothing special about node. So yes, you can use a ruby. Or an Apache, nginx, lighttpd etc.

The reason for this is that JavaScript is run on the client side. The server's response is only to deliver the JS/HTML/CSS files to the client that is visiting your site.

TypeScript

If you're writing an application with TypeScript you need to transpile it to JavaScript before any browser understands it. You can do this (1) before you're deploying your app to the server or (2) use a library like System.js that will transpile TypeScript on the fly.

While (2) is definitely an option and the Angular CLI used it until recently, (1) is in my opinion the better option. Angular CLI switched to (1) and is now using webpack. Webpack is transpiling and bundling your app before it is hosted on a server.

Hope I could clear things up a bit for you.


TL;DR

If you use TypeScript with Angular 2, you only need Node during development:

DEV: NodeJS is used to transpile .ts files to .js files.

PROD: Generated .js files are used inside the browser, NodeJS is not required anymore, except if you also happen use it in the backend.

NOTE: If you only use plain JS in development you do not even need Node


You can use any server side technology including Asp.Net Core, Node.Js, PHP to server the js, html and css content.

While building the application in the IDE, the Node.js transpile the .ts files into .js file.