Reputation: 14959
This is the first line of my Node.js app:
var app = require('http').createServer(handler);
When I try to start it doing node index.js
the result is:
/home/username/public_html/index.js:1
var app = require('http').createServer(handler);
^
ReferenceError: handler is not defined
My Node.js version is 0.12.4
Upvotes: 0
Views: 9873
Reputation: 70085
You say that's the first line of your code. The problem is that you do not define the handler
variable. It should be a function that responds to a request event. Since it is optional, you can (if you wish) leave it out entirely and add handlers for events later on.
var app = require('http').createServer();
Upvotes: 1