I have the following server.js file:
var express = require('express'),
api = require('./api'),
app = express();
app
.use(express.static('./public'))
.use('./api', api)
.get('*', function (req, res) {
res.sendfile('public/main.html');
})
.listen(3000);
and the server.js file is located in C:\Users\myName\Desktop\prodfixes\server.js and main.html is located in C:\Users\myName\Desktop\prodfixes\public\main.html and going to http://localhost:3000/ doesn't throw an error on screen however on the command line (I am using nodemon server.js to run the server) I am getting the error: express deprecated res.sendfile: Use res.sendFile instead. So then I obviously changed res.sendfile to res.sendFile but then I get an error when i refresh the screen:
TypeError: path must be absolute or specify root to res.sendFile at ServerResponse.sendFile (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\response.js:394:11) at C:\Users\myName\Desktop\prodfixes\server.js:9:7 at Layer.handle [as handle_request] (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\layer.js:95:5) at C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:277:22 at param (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:349:14) at param (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:365:14) at Function.process_params (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:410:3)
Sorry I am new to angular and using servers so any help would be greatly appreciated. Thanks.