unable to perform git push in heroku - node.js

I am not able to push my files/repo to heroku it gives an error as follows
$ git push -f heroku main
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: -----> Build
remote: Running heroku-postbuild
remote: > ecommerce#1.0.0 heroku-postbuild
remote: > NPM_CONFIG_PRODUCTION=false && npm install --prefix frontend && npm run build --prefix frontend
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
And yes in my package.json folder I have mentioned the versions of node and npm in engine section
Please anyone help why I am not able to push in heroku

If you use yarn:
git rm yarn.lock
git push heroku master
If you use npm:
git rm package-lock.json
git push heroku master
git push heroku master

Setting Heroku stack. In this case to heroku-20
heroku stack:set heroku-20
then push

Related

Could not find a required file index.js, searched in /tmp/build_43da642b/src

I tried to push my recent code to Heroku. Here is what I got in the console:
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 8 threads
Compressing objects: 100% (26/26), done.
Writing objects: 100% (32/32), 2.90 KiB | 593.00 KiB/s, done.
Total 32 (delta 12), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 16.14.0
remote: engines.npm (package.json): 8.3.1
remote:
remote: Resolving node version 16.14.0...
remote: Downloading and installing node 16.14.0...
remote: npm 8.3.1 already installed with node
remote:
remote: -----> Restoring cache
remote: Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote: Module installation may take longer for this build
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 1403 packages, and audited 1404 packages in 28s
remote:
remote: 175 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 8 vulnerabilities (6 moderate, 2 high)
remote:
remote: To address issues that do not require attention, run:
remote: npm audit fix
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: -----> Build
remote: Running build
remote:
remote: > chatapp-project#0.1.0 build
remote: > react-scripts build
remote:
remote: Could not find a required file.
remote: Name: index.js
remote: Searched in: /tmp/build_1ff4f4ff/src
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 chatapp-project-kasper.
remote:
To https://git.heroku.com/chatapp-project-kasper.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/chatapp-project-kasper.git'
It seems it is searching for a file somewhere. This is my folder structure:
https://i.stack.imgur.com/fISfz.png
I am unsure where this file is, or how I can change where heroku searches for the file. Also, in my Procfile I have this:
web: node src/App.js
Any help would be greatly appreciated.

Getting Problem whlie deploying my nodejs server in heruku

i am building a crud application where in frontend i have used react and in backend i have used nodejs with express. When i try to push my app.js into heroku, i am getting this error.
I have tried so many ways i found in the internet. But still i am getting same error.
git push heroku master
Enumerating objects: 1235, done.
Counting objects: 100% (1235/1235), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1187/1187), done.
Writing objects: 100% (1235/1235), 2.19 MiB | 949.00 KiB/s, done.
Total 1235 (delta 120), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote:
remote: -----> Build failed
remote: ! Two different lockfiles found: package-lock.json and yarn.lock
remote:
remote: Both npm and yarn have created lockfiles for this application,
remote: but only one can be used to install dependencies. Installing
remote: dependencies using the wrong package manager can result in missing
remote: packages or subtle bugs in production.
remote:
remote: - To use npm to install your application's dependencies please delete
remote: the yarn.lock file.
remote:
remote: $ git rm yarn.lock
remote:
remote: - To use yarn to install your application's dependences please delete
remote: the package-lock.json file.
remote:
remote: $ git rm package-lock.json
remote:
remote: https://help.heroku.com/0KU2EM53
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 6f7f0c809a340fce866cad56f94827ead03983b4
remote: !
remote: ! We have detected that you have triggered a build from source code with version 6f7f0c809a340fce866cad56f94827ead03983b4
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to mern-crud-in.
remote:
To https://git.heroku.com/mern-crud-in.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mern-crud-in.git'

Error: failed to push some refs in heroku

I was following a course online on how to deploy in Heroku. I made a Git repository and uploaded and committed all the files there. Then I typed these commands:
heroku create
heroku git:remote -a name_provided_by_heroku
git push heroku main
After command 3 I faced this error in cmd:
Enumerating objects: 4357, done.
Counting objects: 100% (4357/4357), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4125/4125), done.
Writing objects: 100% (4357/4357), 3.64 MiB | 297.00 KiB/s, done.
Total 4357 (delta 935), reused 3 (delta 0), pack-reused 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): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 12.x...
remote: Downloading and installing node 12.20.0...
remote: Using default npm version: 6.14.8
remote:
remote: -----> Installing dependencies
remote: Prebuild detected (node_modules already exists)
remote: Rebuilding any native modules
remote:
remote: > bcrypt#5.0.0 install /tmp/build_88514da7/node_modules/bcrypt
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: sh: 1: node-pre-gyp: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! bcrypt#5.0.0 install: `node-pre-gyp install --fallback-to-build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the bcrypt#5.0.0 install 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.MO7JR/_logs/2020-12-15T17_16_14_007Z-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: Some possible problems:
remote:
remote: - node_modules checked into source control
remote: https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
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 safe-dawn-68695.
remote:
To https://git.heroku.com/safe-dawn-68695.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/safe-dawn-68695.git'
I am new to Heroku, so I am not able to get what the error is saying. Also tried using git push heroku HEAD:master but faced the same error.
How do I solve this?
Refering this article: node-pre-gyp: Permission denied in heroku push
Remove node_modules folder in your root folder rm -rf node_modules beacuse heroku will install all your dependencies, I hope this will work
So remove your node modules folder and do 1 2 3 again

Heroku - EmberJS - Deploy fail ( Unable download node )

when I try to push code on Heroku, the build/deploy fail because of node problem.
Console log
cd dungeon-diary
heroku buildpacks:set https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/emberjs.tgz
git push heroku master
Output console with error
remote: Building source:
remote:
remote: -----> emberjs app detected
remote: -----> Setting NPM_CONFIG_PRODUCTION to false to install ember-cli toolchain
remote: -----> Fetching buildpack heroku/nodejs-v98
remote: -----> Node.js detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 10.* || >= 12
remote: engines.npm (package.json): 6.x
remote:
remote: Resolving node version 10.* || >= 12 via semver.io...
remote: Downloading and installing node 14.7.0...
remote: Unable to download node 14.7.0; does it exist?**
remote:
remote: -----> Build failed
package.json
"engines": {
"node": "10.* || >= 12"
},
The problem was...
in the log you can see, the console choose node 14.7.0 by itself,
but for Heroku it was unacceptable. So I had to explicitly write which version use ( to avoid 14.7.0 ) and it starts work :)
...weird for me why console choose the unsupported version :)

Heroku cedar node app - cannot push master after update to 6.11.1

After updating the node server to version 6.11.1 in response to the recent security update email from Heroku, I cannot git push my local master changes any more. The server and app restarted fine after the update.
I have tried deleted and reinstalled all node_modules, committing the changes and the app runs without errors locally but I get the same build failure when trying to deploy the master. The only change I've made to the package.json file is adding the npm version which was previously unspecified.
From the logs the server build fails when installing node modules:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: npm ERR! Cannot read property '0' of undefined
Is force pushing the best/a good solution?
This is the full logs:
Counting objects: 18, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 8.80 KiB | 0 bytes/s, done.
Total 18 (delta 13), 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: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 6.11.1
remote: engines.npm (package.json): 5.3.0
remote:
remote: Downloading and installing node 6.11.1...
remote: Downloading and installing npm 5.3.0 (replacing version 3.10.10)...
remote:
remote: -----> Restoring cache
remote: Loading 2 from cacheDirectories (default):
remote: - node_modules
remote: - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: npm ERR! Cannot read property '0' of undefined
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2017-07-20T22_54_19_003Z-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 app-name.
remote:
To https://git.heroku.com/app-name.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/app-name.git'
Thanks.
I got the same error message after updating to node 6.11.1 and npm 5.3.0. heroku support suggested that I run these commands:
heroku plugins:install heroku-repo
heroku repo:purge_cache -a APPNAME
git commit --allow-empty -m "Purge cache"
git push heroku master
... where "APPNAME" was the heroku identifier for my app.
That resolved the error and I did not have to revert to an earlier version of npm. I've asked for an explanation but they haven't responded yet (just asked a few minutes ago).
UPDATE 2017-07-27: heroku support responded and said, "We're still working on the root cause for this but it seems to be fairly intermittent." Now that I have installed the plugin (see above), I am running these steps to update my app:
heroku repo:purge_cache -a APPNAME
git push heroku master
That's been working reliably for me.

Resources