It's time to check that Node.js works fine! We are going to write a very small program to begin with, which merely displays a message in the console. This will be an opportunity to see how the execution of .js files works with Node.js.

To begin, open your favorite text editor (vim, Emacs, Sublime Text, Notepad ++ ...) and enter the following JavaScript code:

console.log('Welcome to Node.js!');

Save your file as .js extension. For example test.js.

Next, open a console in the folder where your test.js file is located and enter the command :

node test.js

You should have the following result in the console:

Congratulations, you have created your very first Node.js program! 

Well, that was really easy. We have simply tryed to write a message in the console.
You have seen that to launch a Node.js program you only need to specify the name of the .js file to execute. You know everything you need for the moment!

In later chapters we will deal with serious things in node.js

Younes Derfoufi

Leave a Reply