1. Test Node. To see if Node is installed, open the Windows Command Prompt, Powershell or a similar command line tool, and type node -v. This should print a version number, so you’ll see something like this v0.10.35.
  2. Test NPM. To see if NPM is installed, type npm -v in Terminal. This should print NPM’s version number so you’ll see something like this 1.4.28
  3. Create a test file and run it. A simple way to test that node.js works is to create a JavaScript file: name it example.js, and just add the code console.log('Hello World');. To run the code simply open your command line program, navigate to the folder where you save the file and type node example.js. This will start Node and run the code in the example.js file. You should see the output Hello World.

 

example.js

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});

 

Enter in your browser
http://127.0.0.1:3000/

output
Hello World