I\'m trying to run my first express app, but can\'t seem to get my webpage to show. I have the following code:
var fs = require(\"fs\");
var config = JSON.parse
Your app will only route page requests that are set up at the time of your app.use(app.router)
call. So reorder your app.use
calls to be one of the following:
app.use(express.static(__dirname + "/public"));
app.use(app.router);
__dirname is the directory that the executing script resides in, so because that lives in the js
directory that's a peer to public
your code would need to be:
app.use(express.static(__dirname + "/../public"));
app.use(app.router);
Express 4 removes the need to manually do app.use(app.router). With Express 4 you just need:
app.use(express.static(__dirname + "/../public"));