Heroku Error: ENOENT, stat '/app/build/index.html'

I'm trying to deploy to a hero, but Im getting Error: ENOENT, stat '/app/build/index.html' when I go to my address. Otherwise, deploying the application does not give me any error. Can someone explain what I'm doing wrong. Here is my code and code structure.

server.js

 var express = require('express'), server = express(), bodyParser = require('body-parser'), logger = require('morgan'), methodOverride = require('method-override'); // for heroku var port = process.env.PORT || 5000; server.use(express.static(__dirname + '/build')); server.use('/src', express.static(__dirname + '/build/src')); // js server.use('/assets', express.static(__dirname + '/build/assets')); // css, images server.use('/vendor', express.static(__dirname + '/build/vendor')); // other server.use(logger('dev')); server.get('/', function(req, res, next) { res.sendfile('index.html', { root: __dirname + '/build' }); }); server.listen(port, function() { console.log("Listening on " + port); }); 

App structure

 β”œβ”€β”€ Gruntfile.js β”œβ”€β”€ LICENSE β”œβ”€β”€ Procfile β”œβ”€β”€ README.md β”œβ”€β”€ bower.json β”œβ”€β”€ build β”‚  └── .... β”œβ”€β”€ build.config.js β”œβ”€β”€ config β”‚  └── db.js β”œβ”€β”€ karma β”‚  └── karma-unit.tpl.js β”œβ”€β”€ module.prefix β”œβ”€β”€ module.suffix β”œβ”€β”€ node_modules β”‚  └── ... β”œβ”€β”€ package.json β”œβ”€β”€ server.js β”œβ”€β”€ src β”‚  β”œβ”€β”€ app β”‚  β”œβ”€β”€ assets β”‚  β”œβ”€β”€ common β”‚  β”œβ”€β”€ index.html β”‚  └── less └── vendor 

Structure in app / build

 β”œβ”€β”€ assets β”‚  β”œβ”€β”€ O-viu-0.0.1.css β”‚  └── README.md β”œβ”€β”€ index.html β”œβ”€β”€ karma-unit.js β”œβ”€β”€ src β”‚  └── app β”‚  β”œβ”€β”€ about β”‚  β”‚  └── about.js β”‚  β”œβ”€β”€ app.js β”‚  └── home β”‚  └── home.js β”œβ”€β”€ templates-app.js β”œβ”€β”€ templates-common.js └── vendor β”œβ”€β”€ angular β”‚  └── angular.js β”œβ”€β”€ angular-bootstrap β”‚  └── ui-bootstrap-tpls.min.js β”œβ”€β”€ angular-ui-router β”‚  └── release β”‚  └── angular-ui-router.js └── placeholders └── angular-placeholders-0.0.1-SNAPSHOT.min.js 
+5
source share
2 answers

Figured it out. This was my .gitignore file, in which I included the /build folder.

+5
source

Try something like this:

 res.sendfile( __dirname + '/build/index.html' ); 
0
source

Source: https://habr.com/ru/post/1213075/


All Articles