Getting started with Node.js

Posted by Jake Flavin on July 12, 2018 / How to Articles NodeJS JavaScript

This article is for developers that are new to Node.js. You should already be somewhat confident in JavaScript and have a basic understanding of the language. I am assuming that you already have node and npm installed on your computer. If you do not, go to and follow their installation instructions.

First, open up a command prompt and create a new directory for your "Hello World!" app to live in. The last command will initialize your application and will ask you for some input.

mkdir hello-world
cd hello-world
npm init

Answer the questions the best you can. Leaving some questions blank is okay. When finished, this creates a package.json file in the application's directory. This file will contain important information about your app including JavaScript libraries your application is dependent on.

Next install express.

npm install express --save

This command updates the package.json file with the express dependency and then downloads the needed files into the project's directory. Express is a popular node library that has almost become standard for any node application.  

Fast, unopinionated, minimalist web framework for Node.js

From Express.js’ official website  

Next, open up your favorite text editor (mine is Brackets) and create a new file in the hello-world directory. Call this file index.js. In this file type the following lines:

// Import the needed dependencies 
let express = require('express'); 
let app = express();  

// Define the root of your application
app.get('/', function (req, res) {   
	res.send('Hello World!'); 

// Start the application on port 3000
app.listen(3000, function () {   
	console.log('Hello World app is listening on port 3000!'); 

Start the application.

node index.js

After running the command, go to http://localhost:3000/ in a web browser to see your application running. You should also see the message: “Hello World app is listening on port 3000!” get logged to the command line when the application starts up.

That is it. Happy coding. :)

More Articles

My First Post

Hi, I'm Jake. Welcome to my first blog post!With new technologies emerging every day, it is hard to keep up with all the updates. Blogs are a valuable resource for communicating with fellow engineers, sharing thoughts and ideas, and keeping up with the recent innovations. Since starting my career,...

Posted on May 06, 2018
Getting Started

Support my work!

I love helping people develop on the web. If you enjoy my content, please consider supporting what I do.

The CIA of Security

The CIA of Security is the building block of all security in the IT Security world. These define the important goals of security and answers the question of "Why do we do the things we do?". Confidentiality This is the goal of keeping data secret from people that do not...

Posted on January 15, 2019

Copyright © 2018 Jake Flavin