I get an error trying to render a simple html page using NodeJS and Express 4.10.4, with the following code:
var path = require('path');
var express = require('express');
var logger = require('morgan');
var app = express();
app.set('port', process.env.PORT || 8080);
app.use(express.static(path.join(__dirname, '/client')));
app.set('view engine', 'html');
app.use(logger('dev'));
app.get('*', function (req, res) {
res.sendFile('/index.html');
});
app.use(function (err, req, res, next) {
console.log(err.stack);
res.status(500).send({message: err.message});
});
console.log('Server has started on port: '+ app.get('port'));
My index.html page is within the client folder, it is rendered in my browser but I get the following error:
Error: ENOENT, stat 'c:\index.html'
Has anyone an idea what's the issue?