NPM is a package manager to deliver applications. Its like yum on Centos linux.
In this case, I am installing Cordova for Android development on Centos 7.4 and it required nodejs along with npm. Hence, this article came along the way.
Step 1: Install Epel repository
$ sudo yum install epel-release$ sudo yum info nodejs
It shows nodejs version 6.12.3
Step 2: Install nodejs
Install the development environment then nodejs. This will install together the npm (version 3.10.10)$ sudo yum --setopt=group_package_types=mandatory,default,optional groupinstall "Development Tools"
$ sudo yum install nodejs
Check installed version
$ node -v
$ npm -v
Step 3: Run Hello World
Create this script and name it as helloworld.js to test on a command line and the web browser.var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<p>This is <b>Hello World</b></p>');
}).listen(8080);
console.log('This example is my world!');
At a command line, type
$ node helloworld.js
This should display the output on the command line.
Next, open a web browser and type the following url
localhost:8080
Continue with Cordova installation from previous article.
No comments:
Post a Comment