I have deployed my Angular project to heroku. It's showing error as not found. I tried running the same project in node server.js the same error some files not found. I tried this https://itnext.io/how-to-deploy-angular-application-to-heroku-1d56e09c5147 . But I think there's some error in the server.js file. Server.js
const express = require('express');
const app = express();
const path = require('path');
const port = process.env.PORT || 4200;
const server = require('http').Server(app);
// Serve only the static files form the angularapp directory
app.use(express.static(__dirname + '/RouterApp'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/RouterApp/index.html'));
});
// Start the app by listening on the default Heroku port
server.listen(port, function () {
console.log("App running on port " + port);
})
When I tried putting the path as /src/index.html
, the index page is loading but not the Angular components.
This is my directory structure
>>RouterApp
>>...
>>server.js
>>src
>>index.html
>>components
>>...
Error I'm getting while running using node server.js
ENOENT: no such file or directory, stat '/data/data/com.termux/files/home/RouterApp/RouterApp/index.html'
When I try running the program on localhost:4200
it runs perfectly fine using ng serve
.
Here's the GitHub repo https://github.com/Pradeep2898/QuoraClone