To run nodejs in your localhost you must have to download nodejs from nodejs site /
var http = require('http');
//create a server object
http.createServer(function (req, res)
res.write('Hello World!'); // response to the client
res.end(); // response will end here
}).listen(8000); //the server object listens on port 8080
// This message will print on your command prompt
console.log("Your server is working on port 8000");
Now go to C Drive and open users folders and save this code inside your name folder (What is your computer user name):- C:\users\dheeraj\myfirst.js Now as you can see here dheeraj is my computer name.
Now open command prompt from the same folder where you have saved this file using shift + right click Or See this image
just type node myfile.js & hit enter button this command will start your local server and go to browser type: http://localhost:8000 It will give this output.
You can change port name from here }).listen(8000); Always give free port which is not in use .