I'm starting to learn Node.js. I acquired a guide written by Mark Wandscheider. I downloaded the tools to use it, and I also downloaded the brackets.
I am trying to create a sample script, but I am getting two errors that do not understand and which are missing from the manual.
The first error tells me that:
'require' was used before its definition
C:\node> node debug web.js <Debugger listening on port 5858> connecting ... ok break in C:\node\web.js: 1 1 var http = require ("http"); 2 3 process_request function (req, res) { debug>
and the second (in brackets):
no use of strict instructions
I saw on the Internet that I can add a line
"use strict";
But management does not use it - is it required?
How can I fix these problems?
all code
var http = require("http"); function process_request(req, res) { var body = 'Thanks for calling!'; var content_length = body.length; res.writeHead(200, { 'Content-Length': content_length, 'Content-Type': 'text/plain' }); res.end(body); } var s = http.createServer(process_request); s.listen(8080);
Kevin source share