I do not know if you've already found an answer to your question... But when I look at the code, I see some missing brackets when requiring the express module.
var app = require('express');
Here is the example "Hello World" snippet from the express website
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
They have two lines of code that first includes the express module into the project as the variable "express". Then, they initialize a new express instance (not really, but almost the same):
var app = express();
and THEN they call all functions related to "app". The two first lines of code in the above example is the same as this one line code:
var app = require('express')();
And as you can see, you are missing two brackets.
I also want to point out that you are missing a closing bracket and semi-colon at the very end of your configure function. It should look like this:
app.configure(function(){
app.set('port', 8080);
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, '/public')));
});
So... here is the final code:
var app = require('express')();
app.configure(function(){
app.set('port', 8080);
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, '/public')));
});
app.listen(8080);
Unfortunately the logger and bodyParser middlewares is not longer bundled with express, so you have to install them separately. app.configure is also outdated, so you can get the code to work if you remove the configure function completely, and install the middlewares.
NOTE You are also using path which you have not included to your project install it and add this in the top:
var path = require('path');
So, without any middleware installation, this is the final code that works with the latest version of node and express:
var express = require('express');
var path = require('path');
var app = express();
app.set('port', 8080);
app.use(express.static(path.join(__dirname, '/public')));
app.listen(8080);
OR
var app = require('express')();
var path = require('path');
app.set('port', 8080);
app.use(require('express').static(path.join(__dirname, '/public')));
app.listen(8080);