In my router/index.js
, I am using res.sendfile(..)
as follows:
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res) {
res.sendfile('public/app.html');
});
module.exports = router;
and here is my directory structure:
/Users/lucas/nodeProject/
....app.js
....public/
........app.html
....routes/
........index.js
The purpose of this example is to log into my page via http://myurl.com/
instead of http://myurl.com/app.html
. Everything works fine, except that I get the following message on my server-side console:
express deprecated res.sendfile: Use res.sendFile instead
Does anyone know the cause, and how to fix this? Simply substituting res.sendfile(..)
for res.sendFile(..)
gives me the error:
path must be absolute or specify root to res.sendFile
I have tried other options, outlined here and here to substitute res.sendFile('app.html', { root: path.join(__dirname, '../public') });
, but it only gives me this error:
ReferenceError: path is not defined
Here are my dependencies as well:
"dependencies": {
"express": "~4.8.1",
"static-favicon": "~1.0.0",
"morgan": "~1.0.0",
"cookie-parser": "~1.0.1",
"body-parser": "~1.0.0",
"debug": "~0.7.4",
"jade": "*",
"mongodb": "*",
"mongoskin": "*",
"connect-mongo": "*",
"express-session": "~1.5.1"}
I am also a bit new to node.js, so any suggestions are welcome.