Tuesday 22 May 2018

Angular 2 with NPM hello world


Step 1 : Installing Nodejs

To access to the Node Package Manager (NPM) and run our server, we need to first install Nodejs.

You may already have it installed. To check whether it's installed, visit your console and type:

node -v

If it goes unrecognized, you will need to visit Nodejs.org and visit the downloads page. Choose the installer appropriate for your OS, and install it.


Once complete, reload your console/command line, and re-run the


This time it should provide you with the version installed.


Step 2: Installing Angular

We're going to use the Angular CLI to create our Angular app. Let's install it at the command line through NPM.

npm install @angular/cli -g

  
Give it some time to install once installed go into the any folder where you prefer to store your projects and then run the following command:

ng new mean

cd mean

Once you're in the new project folder, we're going to run a command with the Angular CLI that will create a build of our project. We need to do this because our server is going to look for a /dist folder to serve the files. Run below command to build your project.

ng build



Now Run the Angular 2 application by typing below command.

ng serve


Now, open the browser then go to 
http://localhost:4200 

you should see angular page.


Close the running Angular app first by press ctrl+c



No comments:

Post a Comment

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...