To get started with Node.js, you need to first set its environment. If you are still willing to set up your environment for Node.js, you need the following two software available on your computer, (a) Text Editor and (b) The Node.js binary installable.
Let’s see how to install Node.js binary distribution on Windows. Download the latest version of Node.js installable archive file from Node.js official website.
Use the MSI file and follow the prompts to install the Node.js. By default, the installer uses the Node.js distribution in “C:\Program Files\nodejs”. The installer should set the “C:\Program Files\nodejs\bin” directory in the window's PATH environment variable. Restart any open command prompts for the change to take effect.
After installation, verify it.
Create a js file named main.js on your machine (Windows or Linux) having the following code −
/* first program in node.js */ console.log("Hello, World!")
Now execute the main.js file using Node.js interpreter to see the result −
$ node main.js
If everything is fine with your installation, this should produce the following result −