NodeJS: TypeError: app.use is not a function
I am studying Nodejs tutorials for Connect module.
I wrote this code:
var http = require('http');
var app = require('connect');
function doFirst(request, response, next) {
console.log('doFirst');
next();
}
function doSecond(request, response, next) {
console.log('doFirst');
next();
}
app.use(doFirst);
app.use(doSecond);
http.createServer(app).listen(8888);
and when starting this application, they face the problem:
C:\Users\sparsh\eclipse-workspace\Delete\ConnectServer.js:13
app.use(doFirst);
^
TypeError: app.use is not a function
at Object.<anonymous> (C:\Users\sparsh\eclipse-workspace\Delete\ConnectServer.js:13:5)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
Please, help
+3
source to share