dimanche 6 juin 2021

For some reason webserver won't listen

so I have webServer.js and package.json inside webServer folder and for some reason webserver won't listen when i call it in cmd with node webServer.js

this is my webServer

var http = require('http');


http.createServer(function(req, res){
console.log(req);
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log("***********************************");
console.log(req.url);
res.writeHead(200, {'Content-Type' : 'text/html'});
res.write('hello world');
res.end();
}).listen(80);

and this is package.json

{
  "name": "webserver",
  "version": "1.0.0",
  "description": "",
  "main": "webSever.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

This is what I get when I type in cmd node webServer.js:https://imgur.com/a/p2iK3r4

Aucun commentaire:

Enregistrer un commentaire