Im trying to deploy to heroku but Im getting Error: ENOENT, stat '/app/build/index.html'
when I go to my address. Otherwise the application deployment does not give me any error. Can somebody explain what Im 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);
});
Structure in app
├── 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
Figured it out. It was my .gitignore file where I included the /build
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With