When I try to deploy to Heroku using git push heroku master
I get this error: ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/afternoon-inlet-19669.git'
I found this other StackOverflow question, and it helped me get rid of one of my first errors. Apparently GitHub doesn't update case-changes in file names on commit. So, I realized that I had a file named spinner.js which was actually named Spinner.js on my local machine.
But now, I am getting the error again.
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 12.x
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.0...
Using default npm version: 6.14.4
-----> Installing dependencies
Installing node modules (package.json + package-lock)
> nodemon@2.0.4 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 370 packages from 220 contributors and audited 371 packages in 12.257s
12 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
Running heroku-postbuild
> devconnector@1.0.0 heroku-postbuild /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
> core-js@2.6.11 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js@3.6.5 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.6.5 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
added 1686 packages from 803 contributors and audited 1690 packages in 41.105s
59 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
> client@0.1.0 build /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/components/dashboard/Dashboard.js
Cannot find file '../layout/Spinner' in './src/components/dashboard'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.BfgW5/_logs/2020-06-17T17_40_23_134Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! devconnector@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the devconnector@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.BfgW5/_logs/2020-06-17T17_40_23_146Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
This is a link to my project on GitHub, any idea why Heroku is refusing to push the app? My Project Link
I believe the solution would be to get Github to realize that my file names have changed, it must still think the file is named spinner.js.
UPDATE: 01/22/2021
You can clear the build cache for an app using the following commands:
$ heroku plugins:install heroku-builds
$ heroku builds:cache:purge -a appname
The cache will be rebuilt on the next deploy. If you do not have any new code to deploy, you can push an empty commit.
$ git commit --allow-empty -m "Purge cache"
$ git push heroku master
Where appname is replaced by the name of the app you want to clear the cache for.
OLD ANSWER for previous versions
You should clean your Heroku cache:
heroku repo:purge_cache -a your_app_name
then try again.