AbhishekDwivedi
AbhishekDwivedi

Reputation: 81

unable to execute server.js program using express framework on node.js

While trying to execute server.js program I am getting the following error:

var app = express();
Type error: object is not a function 
   at object.<anonymous>

even tried re installing and changing the version of express to

npm install
npm uninstall express
npm install [email protected]

but it resulted in new error

fqdn = ~req.url.indexof(' ://')

I use windows and i am working on node.js version 0.8.4.

Upvotes: 3

Views: 1458

Answers (2)

Alfred
Alfred

Reputation: 61783

What does

> require('express').version;
'3.0.0rc2'

return?

As you can see it does return 3.0.0rc2? Does yours really return 2.5.9. if it does you use like Brandon said 2.x section. If it returns 3.x you use his 3.x section.

Upvotes: 0

Michelle Tilley
Michelle Tilley

Reputation: 159105

If you're using Express < 3.0, the return value of require('express'); is not a function; you'll need to create a server the old way.

Express 2.x

var express = require('express');
var server = express.createServer();

Express 3.x

var http = require('http');
var express = require('express');
var app = express();
var server = http.createServer(app);

Upvotes: 5

Related Questions