Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running node.js code just displays a node identifier

Tags:

node.js

I have the following code in a file called server.js.

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

I use the command prompt and naviage to the folder where the file recides and then the run the command

node server.js

But I don't get the expected output. Instead I get

The node identifier for {My Machine Name} is v2hrfnqaj.

Note: I already have node installed in my machine and it was working fine.

like image 572
Muthukumar Avatar asked Feb 14 '13 19:02

Muthukumar


People also ask

How does node js code run?

Both your browser JavaScript and Node. js run on the V8 JavaScript runtime engine. This engine takes your JavaScript code and converts it into a faster machine code. Machine code is low-level code which the computer can run without needing to first interpret it.

How do I know if node js is running?

To check the node server running by logging in to the system In windows you can simply go to the Task Manager and check for node in the application list. If it is there then it is running in the machine.

Which command will show version of node?

Explanation. Executing $ node --version command will show the version of Node instance.


1 Answers

You can also prioritize in the environments. Steps: Computer -> Right click -> Properties -> Advanced system settings -> Environment variables -> PATH(in system variables list) -> Edit -> Prioritize by moving up

like image 137
Ravindu Anjana Avatar answered Sep 22 '22 03:09

Ravindu Anjana