Answer the question
In order to leave comments, you need to log in
404 error when starting the server. What could be the problem?
Here is the code in the books from Osmani's book :
// Module dependencies.
var application_root = __dirname,
express = require( 'express' ), //Web framework
bodyParser = require('body-parser'), //Parser for reading request body
path = require( 'path' ), //Utilities for dealing with file paths
mongoose = require( 'mongoose' ); //MongoDB integration
//Create server
var app = express();
//Where to serve static content
app.use( express.static( path.join( application_root, 'site') ) );
app.use(bodyParser());
//Start server
var port = 4711;
app.listen( port, function() {
console.log( 'Express server listening on port %d in %s mode', port, app.settings.env );
});
Cannot GET /
app.get('/', function (req, res) {
res.render('index', {});
});
Answer the question
In order to leave comments, you need to log in
The path to the statics is incorrect, you may not have an index file. Now you have express looking for an index file in the root of the application, do you have it there?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question