NodeJs is the trending technology these days. NodeJS is an open source and server-side programming. In this tutorial, I am going to share how to run hello world program in node.js with the output.
First, you need to install nodejs in your machine to run the nodejs application. Here is details tutorial:
Create a file “index.js” inside any folder and copy paste below code and save it.
1 2 3 4 5 6 | var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World!'); }).listen(8080); |
1. Now open the command window and navigate to your working directory using cd command
.
2. Run node index.js
command to run your program.
3. Open “http://localhost:8080/” in your browser to see the program output.
1. Copy the below code and paste it in index.js page.
1 | console.log('Hello World!'); |
2. Run node index.js
command to see the output.
If you like this tutorial, do like and share with your friends on social media sites and don’t forgot to subscribe our blog to get latest tutorials inside your mail box.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.