Install Node.js, npm, and Angular on CentOS 7.x

Node.Js

Node.js is a cross-platform, open-source JavaScript library for server-side, contrary to previous practice of using JavaScript primarily for client-side scripting by embedding the scripts in a webpage’s HTML. Node.js provides asynchronous I/O capability out of the box with it’s event-driven architecture. Node.js has been adopted by major corporations, including IBM, LinkedIn, Microsoft, Netflix, Paypal, GoDaddy, Walmart, Cisco systems, a lot more.

npm

NPM is the package management utility for the JavaScript programming language i.e. Node.js, Angular. It provides a command-line client for consuming and distributing the JavaScript modules from the remote registry . Easiest (most common way) to install npm is installing the Node.js, it has it as the default package manager. Currently npm registry has 347,184 packages, and there’s no approval process for submission of the package, you have to check the number of downloads and depending packages as a assurance of a good quality module. For more you can check the npm page.

Angular

Angular is an open-source JavaScript front-end web application framework mainly for developing single-page applications. There’s some confusion regarding the name and version of Angular, initially it was started as AngularJS framework (which is still v1), but later on it was completely re-written and released as Angular 2 in September 2016. In March 2017, Angular 2 was renamed as Angular.

Step 0 – Install the pre-requisites

Node.js gets installed from the NodeSource repository which requires the EPEL repository
sudo yum -y install epel-release
As we’ll be using npm to install angular CLI, it requires few build tools to compile and install packages
sudo yum -y install gcc c++ make

Step 1 – Install Node.js

Option 1: Install Node.js using yum

sudo yum -y install nodejs
Checking the versions
nodejs-yum

Option 2: Install latest Node.js

In my case Node.js v6 got installed which is the LTS (Long Term Support). Currently the latest available node.js is v9, and latest LTS is node.js v8. if you have recently run the ‘yum update’ you may get the node.js v8 installed. For installing the latest node.js v9, use the following steps – can remove the previously installed node.js using ‘sudo yum -y remove nodejs’.
Add the NodeSource repository for the version you want to install i.e. Node.js v9.x
curl -sL https://rpm.nodesource.com/setup_9.x | sudo -E bash -
Install node.js
sudo yum -y install nodejs
Verification
nodejs-latest

Step 2 – Install Angular

Installing Angular manually was cubersome, but thanks to the development team for introducing the Angular CLI. Angular CLI jumpstarts the development with Angular, it’s a mere command-line interface allowing users, from creating to deploying an Angular application. Once installed angular-cli provides a command-line utility ‘ng‘ to handle anything related to angular.
npm install -g @angular/cli
Verification
angular-cli

Start a Angular project

The following command generates the project structure, with pre-configured files for unit tests and bundling with the powerful Webpack bundler.
ng new <project-name>
angular-project

Staring the development server

cd <project-name>
ng serve
Output:
ng-serve
The angular application is accessible at http://localhost:8005 – you can verify it in your browser.

Leave a Reply

Your email address will not be published. Required fields are marked *