Question

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

Posted March 2, 2016 3.3k views
UbuntuNode.jsNetworkingConfiguration Management

Following the tutorial mentioned above, part 4, rewriting app.js,
I get this error, any suggestion on how to correct it?
/root/socketio-test/app.js:9
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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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.

Submit an Answer