How to run hello world program in node.js

I know we all have the tendency to skip the steps while following a methodology, but running a program in node.js is very simple if you follow these steps:-

Firstly download the node.js from “official website“, if you have already done it it’s fine.

InStructions for Windows
Click on downloads and select the .msi   file based on your operating system and system type.

To know your computer’s operating system and system type ‘Open My Computer then do right click and click on properties’.

Install node.js by double clicking on the downloaded file and following the instructions.

Before creating any files i prefer keeping the files in a separate folder, hence i created a folder in c: drive named node.

Now open a text editor and type   console.log(“hello World!”);   and save the file with .js extension in the folder created.

Open command prompt and navigate to the folder where the file is saved and execute   node filename.js.

In my case i navigate to node folder by executing   “cd node” and run the file by  “node helloworld.js.”

Note:-If you have opened the node shell the command prompt with node symbol on it, you’re already in node so you don’t have to execute through any   file. Here you can directly type
console.log(“Hello World!”);

Consider looking into complete End to End development with Node.js

Installing Node on Mac

Tagged as: ,