0

I have the following file:

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

app.configure(function () {
    app.set('port', 3000);
    app.use(express.static(__dirname + '/public'));
});

httpServer.listen(app.get('port'), function () {
    console.log("Express server listening on port %s.", httpServer.address().port);
});

However this gives the follow errors:

C:\var\www\stage.mayfieldafc.com>nodemon http.js
18 Jul 01:19:29 - [nodemon] v1.2.1
18 Jul 01:19:29 - [nodemon] to restart at any time, enter `rs`
18 Jul 01:19:29 - [nodemon] watching: *.*
18 Jul 01:19:29 - [nodemon] starting `node http.js`

C:\var\www\stage.mayfieldafc.com\http.js:8
app.configure(function () {
    ^
TypeError: Object function (req, res, next) {
    app.handle(req, res, next);
  } has no method 'configure'
    at Object.<anonymous> (C:\var\www\stage.mayfieldafc.com\http.js:8:5)
    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:906:3
18 Jul 01:19:29 - [nodemon] app crashed - waiting for file changes before starting...

After installing both nodemon and express and I can see both folders inside of node_modules

Also when console logging the return of express I see that it has correctly loaded the module.

How can I verify my node install? Or better still fix it.

2 Answers 2

1

Express 4 no longer has app.configure(). See the wiki on migrating from Express 3 to Express 4.

Sign up to request clarification or add additional context in comments.

Comments

1

The method app.configure has been removed from express 4. So now you have to say something like bellow.

app.set('port', 3000);
app.use(express.static(__dirname + '/public'));

instead of

app.configure(function () {
    app.set('port', 3000);
    app.use(express.static(__dirname + '/public'));
});

and there are many other changes has been made.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.