How To Install Express, a Node.js Framework, and Set Up Socket.io on a VPS...Part 4: The Server Code

March 2, 2016 988 views
Node.js Configuration Management Networking Ubuntu

Following the tutorial mentioned above, part 4, rewriting app.js,
I get this error, any suggestion on how to correct it?
var app = express();
TypeError: object is not a function
at Object.<anonymous> (/root/socketio-test/app.js:9:11)
at Module.compile (module.js:456:26)
at Object.Module.extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

1 Answer

express() can be used to create a server in express 3.x.x but in earlier versions the command would be

var app = express.createServer();

That would be the most common reason for the issue you're seeing. The other possibility is that express was not installed properly via npm, re-doing the install may correct this if changing the express() call does not.

Have another answer? Share your knowledge.