Skip to content

NodeJs Hello World

  • by

A Nodejs “Hello World” program is a simple program that displays the message “Hello, World!” on the screen. It is often used as a basic introduction to a programming language or platform.

Node.js is a free, open-source, cross-platform JavaScript runtime environment that allows you to build scalable and high-performance applications using JavaScript on the server side. It uses an event-driven, non-blocking I/O model, which makes it efficient and suitable for real-time applications.

To install Node.js on your computer, you can follow these general steps:

Windows:

  1. Go to the official Node.js website (https://nodejs.org/en/download/) and download the Windows installer for the current version of Node.js.
  2. Double-click the downloaded installer file and follow the prompts to install Node.js.
  3. Open the command prompt by pressing Win + R and typing cmd, then press Enter.
  4. Verify that Node.js and npm are installed by running the following commands:
node -v
npm -v
Verify version Node js and npm in cmd

macOS:

  1. Go to the official Node.js website (https://nodejs.org/en/download/) and download the macOS installer for the current version of Node.js.
  2. Double-click the downloaded installer file and follow the prompts to install Node.js.
  3. Open the Terminal app by going to Applications > Utilities > Terminal.
  4. Verify that Node.js and npm are installed by running the following commands:
node -v
npm -v

Linux:

The installation steps for Node.js and npm may vary depending on your Linux distribution. Here are the general steps:

  1. Open a terminal window.
  2. Install Node.js and npm using your distribution package manager. For example, on Ubuntu or Debian, you can run the following command:
sudo apt-get install nodejs npm

On Fedora or CentOS, you can run the following command:

sudo dnf install nodejs npm

3. Verify that Node.js and npm are installed by running the following commands:

node -v
npm -v

NodeJs Hello World example

Simple example code.

1. Create a new file called app.js in a directory of your choice.

Create a new file app js

2. In the app.js file, add the following code:

console.log("Hello, World!");
app js hello wrold code

3. Open a terminal or command prompt in the directory where the app.js file is located.

4. Run the following command to execute the app.js file:

node app.js

Output:

NodeJs Hello World

Do comment if you have any doubts or suggestions on this Basic and first code of Node js topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading