javascript - Node.js server.get() TypeError: undefined is not a function -


var express = require('express'),     http = require('http'),     app = express(),     server = http.createserver(app),     io = require('socket.io').listen(server), //pass http.server instance     fs = require('fs');  server.listen(8008);  // routing server.get('/', function (req, res) {   res.sendfile(__dirname + '/chat.html'); }); 

i have code creates server. when run following error: typeerror: undefined not function

server.get('/', function (req, res) {        ^ typeerror: undefined not function     @ object.<anonymous> (c:\users\rexhi\desktop\private_mess\app.js:11:8)     @ module._compile (module.js:460:26)     @ object.module._extensions..js (module.js:478:10)     @ module.load (module.js:355:32)     @ function.module._load (module.js:310:12)     @ function.module.runmain (module.js:501:10)     @ startup (node.js:129:16)     @ node.js:814:3 

what wrong here? i'm new node.

the .get(req,res) function belongs instance of express. thus, should do:

app.get('/', function (req, res) {     .. }); 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -