My server.js file looks like this:
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);
The server.js file is located in C:\Users\myName\Desktop\prodfixes\server.js and main.html can be found in C:\Users\myName\Desktop\prodfixes\public\main.html. When I visit http://localhost:3000/, no error is displayed on the screen. However, when running the server using nodemon server.js, I encounter the following error message: express deprecated res.sendfile: Use res.sendFile instead. After updating res.sendfile to res.sendFile, a new error occurs upon refreshing 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)
I am still learning Angular and server setup, so any guidance would be highly appreciated. Thank you.