jackhelsi
jackhelsi

Reputation: 169

ENOENT: no such file or directory, stat '/app/client/build'"

I am developing a web app using reactjs and nodejs technologies and after that, I deployed it on HEROKU, but when I run on Heroku it gives me an error ENOENT: no such file or directory, stat '/app/client/build'" and I observe one thing stat '/app/client/build' this path not change at anytime I dont know why because I am a new learner in reactjs and nodejs.

server.js

    var restify = require("restify");
    var server = restify.createServer();
    
    function respond(req, res, next) {
        res.send('Hello Restify!');
    }
    
    server.get('/hello', respond);
    server.get("/*", restify.plugins.serveStatic({
      directory: __dirname+"/client/build",
      default: 'index.html',
      appendRequestPath: false
     })
    );
    var port = process.env.PORT || 5000;
    server.listen(port, function() {
        console.log("Listening on " + port);
    });

Upvotes: 0

Views: 3719

Answers (1)

ConfusionPrevails
ConfusionPrevails

Reputation: 11

The reason why this might be erroring out is because the /client/build directory might not exist.

  • Make sure when you do a git add you are including this folder (i.e maybe you have .gitignore file that is excluding this directory
  • Once you push to heroku, you can verify all the files on the server by:
heroku run bash # should take you to the current dyno's bash
ls              # do you see your client directory?
cd client 
ls              # do you see your build directory?

Upvotes: 1

Related Questions