---
title: "Hello World in Node.js"  
description: "In this article, we describe the example of hello world in node.js."  
author: "Anchal Kesharwani"  
published: 2014-08-18  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1458/hello-world-in-node-js  
category: "node.js"  
tags: ["node js"]  
reading_time: 1 minute  

---

# Hello World in Node.js

In this [article](https://yourviews.mindstick.com/view/81489/kashmir-now-after-an-year-of-abrogation-of-article-370), we [describe](https://www.mindstick.com/interview/12752/what-is-ddms-describe-some-of-its-capabilities) the example of [hello world](https://www.mindstick.com/forum/23190/why-does-this-code-using-random-strings-print-hello-world) in [node.js](https://www.mindstick.com/interview/33773/why-is-node-js-single-threaded).If you want to learn how to [install](https://www.mindstick.com/articles/12876/the-top-5-reasons-to-buy-and-install-a-tonneau-cover) and setup node.js first, then you can read my [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) article using below link:

http://www.mindstick.com/Articles/6936b641-b351-481c-900c-7741a5b42fd7/Install%20and%20Setup%20Node%20js

We open the [command prompt](https://answers.mindstick.com/qa/51716/how-to-make-bootable-pendrive-using-cmd-windows-command-prompt) with administrator and change the [location](https://www.mindstick.com/news/2574/twitter-conveniently-reveals-a-location-sharing-policy-amid-elonjet-controversy) where you want to keep your [js file](https://www.mindstick.com/forum/23051/calling-js-file-function-from-code-behind) as like this:

C:\node;

![Hello World in Node.js](http://www.mindstick.com/MindStickArticle/204435ef-1ee4-4c66-abaa-97875696943a/Images/image001.png)

\
Let we go to create a simple program for Hello world in node.js. Here, where we want to store our file we create a test.js file and select through command prompt but here we select c:\node folder and code into test.js file:

```
var http = require('http');http.createServer(function (req, res) {    res.writeHead(200, {'Content-Type': 'text/plain'});    res.end('Hello World\n');}).listen(1337, "127.0.0.1");console.log('Server running at http://127.0.0.1:1337/'); 
```

To run this program command prompt type the node filename.js

![Hello World in Node.js](http://www.mindstick.com/MindStickArticle/204435ef-1ee4-4c66-abaa-97875696943a/Images/image003.png)

And run on the browser:

![Hello World in Node.js](http://www.mindstick.com/MindStickArticle/204435ef-1ee4-4c66-abaa-97875696943a/Images/image005.png)

The output of the test.js file by node.js. I hope that this article is helpful for you.

---

Original Source: https://www.mindstick.com/articles/1458/hello-world-in-node-js

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
