简体   繁体   中英

Receiving error message about syntax nodejs

I am new to Node js. I am following this tutorial online. I was trying to test the code but I get an error every time about line 1 syntax error and I got the code from the tutorial so I am not sure what the problem is? Can someone help me please? Thanks in advance

//Here is the code

     myfirst.js

     var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');
}).listen(8080);
var http = require('http');

//create a server object:
http.createServer(function (req, res) {
  res.write('Hello World!'); //write a response to the client
  res.end(); //end the response
}).listen(8080); //the server object listens on port 8080

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM