I'm about to send a simple project that is working perfectly on my local computer, and I need to send it to the Heroku server, so it's necessary to configure a file that will simulate the Node Express in the Angular, project that I performed with the command ng build --prod
.
When executing the command was creating a folder called dist in the project root, and then I configured the server.js file as you can see below;
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/dist'));
app.get('/*', function(req, res) {
res.sendFile(__dirname + '/dist/index.html');
});
app.listen(4200);
Once configured, you had to run the node server.js
command to upload the application using the Node server.
To verify that everything was correct I entered the URL http://localhost:4200/
and returned the following error message below;
C: \ Blog \ API \ api \ blog> node server.js Error: ENOENT: no such file or directory, stat 'C: \ Blog \ API \ api \ blog. \ index.html'
This message indicates that the node server is not finding the main project file that is index.html
, but I do not understand why this is happening and I need help.