Search code examples
angular2-routingangular2-formsangular2-services

How to run angular 2 application?


I have downloaded angular 2 application from this link:

https://github.com/aravindfz/firstAngular2App

How to run this application? Which angular cli version install to run angular 2 application? I tried from some questions stackoverflow but not working properly.guys this question is not duplicate..Please understand. Anyone can give clear details? I need step by step procedure.


Solution

  • If you cloned the repo and did nothing else, there are a few things you need to do before you can run the app. Since I don't know how much web development you have done, I'm going to include things some people will think unnecessary.

    1. Install node.js, if you haven't yet. Grab the LTS release from https://nodejs.org/en/. Do not use the "Current" version, because that may not be compatible with Angular just yet. If you have and older version of Node, upgrade. If you already have the LTS version, skip this step.
    2. Now open a new command prompt or terminal and change to the directory where you cloned the repo. To be sure you're in the right place, make sure you can see a file named package.json.
    3. In this command prompt/terminal window, execute this command: npm install. This will download and install all the dependencies (which could rather disturbingly add up to a few hundred Megabytes). You may experience timeout errors if you're behind a corporate proxy server. That's not something you can fix as of 2018. Just connect using something else and try again.
    4. Once everything is installed, you should be able to run the Angular app. Everything I mentioned already only need to be done before you run it the first time. To ensure you are in the right folder, navigate to where your index.html is located and run this command: ng serve. If ng cannot be found, you may need to install it. To do so, execute npm install --save-dev @angular/cli. Now it should work. If not, close your command prompt/terminal window, open a new one and try ng serve again.
    5. Once ng serve is finished compiling, you should be able to view your app by opening http://localhost:4200 in your favourite browser.

    And that's it!

    Here's a bonus tip: Take the time to work through the official Angular Quick Start. It really is a fantastic guide and will get you skilled up much quicker than just hacking it ever will.

    Good luck.