Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Node.js


1. Node.js
Node.jsNode.jsĀ® is a JavaScript runtime built on Chrome's V8 JavaScript engine. ... As an asynchronous event driven JavaScript runtime, Node is designed to build scalable network applications. From the Node.js web site at http://https://nodejs.org .

Node.js, or just Node, is a JavaScript-based system for server-side actions involving communication (e.g., web server processing). Node.js can also be used for command line processing, robotics control, etc.

The Node package manager is called npm, for "Node Package Manager".

2. CentOS 7 installation
The following Linux command(s) add the Node.js repository so yum can find node to install.
cd ~ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -

The following Linux command(s) install Node.
sudo yum -y install nodejs


3. Verify the version
The following Linux command(s) check the installed node version.
node --version

On 2019-08-09 the output was as follows.
v10.16.2

The following Linux command(s) check the installed npm version.
npm --version

On 2019-08-04 the output was as follows.
6.9.0


4. Hello world in JavaScript
The file type of a JavaScript program file is js.

The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.js

Create the following program text in the editor that will output the text "Hello world"
console.log("Hello world");

To exit with save, remember to press Ctrl-X, then "y" (for yes) and Enter to exit.

The following Linux command(s) run the program.
node ~/hello.js

The output should be as follows.
Hello world


5. End of page