node is not defined

I just create a js file with the following code(exactly the code from official page):

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/');

So, I install node from the 'Install' button in the official page too(for windows). But when I try to run the program it gives me the following:

enter image description here

but the strange thing is this:

enter image description here

You need to run that from your terminal (cmd) as opposed to Node's repl.

Try opening up a new terminal (Run -> CMD) and then executing:

node /your_file_name.js

To see which version you have installed, just execute:

node -v

You're at the console. You probably want to run node server.js from the Windows Command Prompt (cmd.exe).

did you add node directory to your PATH.

If you install the latest one, the installer would add it for you

There are two things needed to do.. First you need to add an environment variable. like path=C:\Program Files\nodejs for me. Second.. you have to open the command prompt then redirect the prompt to the location where you have kept your file.. like if you have kept your file on c:/practice and your file name is server.js then you have to redirect the command prompt to that location.

And then run the command node server.js and everything will work properly..