Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find a required file index.html - Heroku push error

I am pushing the react-node app to Heroku using Heroku CLI.

build is failing and the error is Could not find a required file index.html

I have checked all the files and everything in place

don't know what am I missing?

I am stuck here for one week.

Please help me


I am pushing the react-node app to Heroku using Heroku CLI.

build is failing and the error is Could not find a required file index.html

I have checked all the files and everything in place

don't know what am I missing?

I am stuck here for one week.

Please help me

Package.json
"main": "server.js",
  "scripts": {
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },

Error :

Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 398 bytes | 398.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  8.9.4
remote:        engines.npm (package.json):   6.2.0
remote:
remote:        Resolving node version 8.9.4...
remote:        Downloading and installing node 8.9.4...
remote:        Bootstrapping npm 6.2.0 (replacing 5.6.0)...
remote:        npm 6.2.0 installed
remote:
remote: -----> Restoring cache
remote:        - node_modules
remote:
remote: -----> Building dependencies
remote:        Installing node modules (package.json)
remote:        audited 2601 packages in 4.802s
remote:        found 0 vulnerabilities
remote:
remote:        Running heroku-postbuild
remote:
remote:        > [email protected] heroku-postbuild /tmp/build_cb13714e30f186bd579e6f8f21bf9383
remote:        > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote:
remote:        > [email protected] postinstall /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client/node_modules/jss
remote:        > node -e "console.log('\u001b[35m\u001b[1mLove JSS? You can now support us on open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/jss/donate\u001b[0m')"
remote:
remote:        Love JSS? You can now support us on open collective:
remote:         > https://opencollective.com/jss/donate
remote:
remote:        > [email protected] postinstall /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client/node_modules/uglifyjs-webpack-plugin
remote:        > node lib/post_install.js
remote:
remote:        added 1375 packages from 852 contributors and audited 13755 packages in 46.845s
remote:        found 0 vulnerabilities
remote:
remote:
remote:        > [email protected] build /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client
remote:        > react-scripts build
remote:
**remote:        Could not find a required file.
remote:          Name: index.html**
remote:          Searched in: /tmp/build_cb13714e30f186bd579e6f8f21bf9383/client/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! [email protected] build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the [email protected] build scr`enter code here`ipt.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.bspBQ/_logs/2018-10-14T10_57_59_194Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! [email protected] heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the [email protected] heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.bspBQ/_logs/2018-10-14T10_57_59_208Z-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     **Push rejected, failed to compile Node.js app.**
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to murmuring-depths-54253.
like image 518
Mani Avatar asked Oct 14 '18 11:10

Mani


2 Answers

I also encountered this issue today and managed to fix it by removing /public folder from .gitignore.

Two things could be cause of this:

  1. Probably you have /public directory specified inside your .gitignore
  2. Case sensitive paths

more info at: https://create-react-app.dev/docs/deployment/#heroku

like image 171
Anurag Hazra Avatar answered Sep 30 '22 05:09

Anurag Hazra


Possible Solution: Your file structure might be the issue

By chance do you have an 'api' folder next to your 'client' folder?

  • Heroku doesn't seem to play well with certain file structures (not sure why, I opened a ticket with them to inquire)

  • I was receiving almost the exact same error because I had most of my 'server' files within an api folder at the root.

  • After moving those files outside the api folder, removing my lock files, and reinstalling node modules, deployment went off without a hitch.

So, try the following:

  1. Make sure that your file structure isn't conflicting with standard deployments (see screenshot below)

  2. Remove your lock files and node_modules

  3. Reinstall node_modules at root and in client

  4. commit and and attempt another deploy -- let us know if that succeeds

As you can see, the only difference is the location of those folders within the api folder (obviously, import/require pathnames needed to be updated as well)

Failing Folder Structure

This file structure fails with the same error message

Successful Folder Structure

This file structure succeeds as expected

like image 24
SethGoodluck Avatar answered Sep 30 '22 05:09

SethGoodluck