How to Run Simple HelloWorld NodeJS script in Linux CentOS virtual server

Posted on

This article is an article where the main focus is to execute and run a simple NodeJS script in Linux CentOS virtual server. Actually, before executing or running a simple NodeJS script in Linux CentOS server or any server available, install the NodeJS first. There is a reference in the article with the title of ‘How to Install NodeJS in Linux CentOS 8 virtual server’ in this link.  So, after successfully install the NodeJS program, just follow these sequence for executing a simple HelloWorld NodeJS script :

1. Access the virtual server, directly to the virtual server or remotely access the virtual server. Accessing the virtual server remotely is possible by using one of the method available. For an example, accessing using SSH connection method. Check the article with the title of ‘How to Remote CentOS Virtual Server running in a VirtualBox with a NAT Network using SSH’ in this link.

2. After successfully logging in to the virtual server. Create a new file with the extension of ‘*.js’. Use any text file available in the operating system. For an example, just execute the following command :

[root@10 nodejs]# vim hello_world.js

3. After successfully executing the above command, a blank display hinting the appearance of a new file with the name of ‘hello_world.js’. Just iinsert the following line of code in that file :

console.debug("Hello World !");

4. After inserting the above line in the file, do not forget to save it. After that, just close the file. Finally, using the following command just execute the NodeJS script in order to run it :

[root@10 nodejs]# node hello_world.js
Hello World !
[root@10 nodejs]#

The above output command will present series of string of ‘Hello World !’. So, the above NodeJS script execution is a success for displaying ‘Hello World’ in the console. It is quite simple and easy just to check that the NodeJS tool is working.

One thought on “How to Run Simple HelloWorld NodeJS script in Linux CentOS virtual server

Leave a Reply