From e1910d2832f1096f2ba10c97ca406c7367cd1a6e Mon Sep 17 00:00:00 2001 From: Davis Abubakr-Sadik Nii Nai Date: Thu, 2 Oct 2014 19:15:49 +0000 Subject: [PATCH 1/2] fix sendFile deprecated. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 6ffcb1db..6c0c9472 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ - res.sendfile('index.html'); + res.sendFile('index.html'); }); io.on('connection', function(socket){ From e6d6776d23a3a06ea709beb01067702d5188119f Mon Sep 17 00:00:00 2001 From: Stephen Thomas Robbins Date: Sun, 9 Nov 2014 14:45:45 -0500 Subject: [PATCH 2/2] sendFile requires absolute path or specified root Just replacing "sendfile" with "sendFile" results in "TypeError: path must be absolute or specify root to res.sendFile". I think specifying an absolute path utilizing the __dirname Node.js global is best, rather than introducing the options object for sendFile. http://nodejs.org/docs/latest/api/globals.html#globals_dirname http://expressjs.com/api.html#res.sendFile --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 6c0c9472..a322dca0 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ - res.sendFile('index.html'); + res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){