Sunday, 11 June 2017

Connect is not a function Node.js

I am trying to export Connectas an middleware for an HTTP server test, but when I execute the code, it says the follow :

connect.createServer is not a function

My code :

hello_world.js

function helloWorld(req, res) {
res.end('Hello World!');
}
module.exports = helloWorld;

hello_world_app (where the problem is) :

var connect = require('connect');
// import middlewares
var helloWorld = require('./hello_world');
var app = connect.createServer(helloWorld);
app.listen(8080);

He points out to the hello_world_app in the var app, saying that is not a function. How can I make this work ?



via Monteiro

No comments:

Post a Comment