I try to master node.js but the error here falls out the code index.js

var server = require("./server"); var router = require("./router"); server.start(router.route); 

server.js

 var http = require("http"); var url = require("url"); function start(route) { function onRequest(request, response) { var pathname = url.parse(request.url).pathname; console.log("Request for " + pathname + " received."); route(pathname); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); } http.createServer(onRequest).listen(8888); console.log("Server has started."); } exports.start = start; 

router.js

 function route(pathname) { console.log("About to route a request for " + pathname); } exports.route = route; 

what this error means I know. But why she arises do not understand. Explain ah? Here is the full text of the error.

 Request for / received. C:\OpenServer\domains\mayapp\server.js:6 route(pathname); ^ ReferenceError: route is not defined at Server.onRequest (C:\OpenServer\domains\mayapp\server.js:6:5) at emitTwo (events.js:87:13) at Server.emit (events.js:172:7) at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:533:12) at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23) 
  • Take out the function from the function - Andrey Shpilevoy
  • @AndreyShpileva you mean that I am passing a function to a function? - Sergalas
  • The code you gave wound up safely with me, here . - Alexander Igorevich
  • @AlexanderIgorevich I don’t deny that it will start up safely somewhere, or I don’t understand why it doesn’t start up. - Sergalas
  • Judging by the numbers of lines in the stack, the code in the response and your computer are different. - Aleksei Zabrodskii

0