Search code examples
node.jsnodejs-server

Node server is not starting(command executes but not start the port)?


when I enter "node server.js" then execution start and the cursor stuck at the starting of the next line what is the error.

const http = require('http');
http.createServer((req, res) => {
    console.log("hi from server");
    res.end('ok');
}).listen(8000);

Image


Solution

  • This is normal behaviour in fact if you add this line

    console.log("Hi from Server");
    

    Before

    res.end("ok");
    

    the cursor will print "hi from server" and return to the same state..