Error: failed to push some refs in heroku - node.js

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

Related

Heroku deploy error - ! [remote rejected] master -> master (pre-receive hook declined)

I have seen many people get this error, and I've tried every solution I've seen suggested so far. Checking if Heroku knows what kind of app it is, removing .git file from my client folder and so on. In the error message, I can see it is having trouble finding the files, but I don't know how I'd fix this as I did git add -A and git add . numerous time. I am a beginning and I am not sure what I'm missing.
This is the error message when I do git push heroku master:
Counting objects: 100% (13/13), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (13/13), 13.79 KiB | 1009.00 KiB/s, done.
Total 13 (delta 0), reused 0 (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.18.3...
remote: Using default npm version: 6.14.6
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote: added 131 packages in 5.646s
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > mern_project#1.0.0 heroku-postbuild /tmp/build_07c4cff9
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote: up to date in 0.242s
remote: found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_07c4cff9/client/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_07c4cff9/client/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.LOFwn/_logs/2020-08-28T19_01_14_938Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! mern_project#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run
build --prefix client`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the mern_project#1.0.0 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.LOFwn/_logs/2020-08-28T19_01_14_958Z-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 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 floating-island-87176.
remote:
To https://git.heroku.com/floating-island-87176.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/floating-island-87176.git'
Add engines in package.json file
"engines": {
"node": "16.13.0",
"npm": "8.1.0"
},
Then, change version of the package.json
"version":"1.2.1"
Then
git push heroku master
As found in this github issue it was an error with the git repo still thinking client was a submodule. The fix is to remove the client folder from git tracking and add it back as regular files:
git rm -f --cached client && git add . && git commit -m 'Add client folder back to git repo' && git push heroku master
This is what worked for me (The branch is based on 'origin/master', but the upstream might be gone.
(use "git branch --unset-upstream" to fixup))
git branch --unset-upstream

Heroku CI/CD with npm private packages

Anyone have any ideas what the issue here is, it seems to be evaluating my npm registry to False. I am installing packages from a private scope.
I have added an .npmrc file as well and added
#scope:registry=https://registry.npm.org
//registry.npmjs.org/:_authToken=${NPM_PRIVATE_TOKEN}
When I echo the variable from heroku in my console I see that NPM_PRIVATE_TOKEN is already set
heroku config:get NPM_PRIVATE_TOKEN --app xxxxx
xxxx-xxxx-xxxx-xxx-xxxxxxxx
Total 530 (delta 244), reused 331 (delta 140)
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=False
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 12.x.x
remote: engines.npm (package.json): 6.x.x
remote:
remote: Resolving node version 12.x.x...
remote: Downloading and installing node 12.18.4...
remote: Bootstrapping npm 6.x.x (replacing 6.14.6)...
remote: npm 6.x.x installed
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json)
remote: npm ERR! code E404
remote: npm ERR! 404 Not Found - GET https://registry.npmjs.org/False - Not found
remote: npm ERR! 404
remote: npm ERR! 404 'False#latest' is not in the npm registry.
remote: npm ERR! 404 Your package name is not valid, because
remote: npm ERR! 404 1. name can no longer contain capital letters
remote: npm ERR! 404
remote: npm ERR! 404 Note that you can also install from a
remote: npm ERR! 404 tarball, folder, http url, or git url.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.QbXAj/_logs/2020-09-24T17_46_48_753Z-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
rem
Well this was a silly error on my part I was setting my env variables and accidentally set
NPM_CONFIG_PRODUCTION to False instead of false.

I need to push my app to heroku via git, but i get error "Push failed

I have my app created with node.js, I need to push it to my repository in heroku, but is get an error of push failed, i have included error information appear from my console. Please anyone who can help me
$ git push heroku master
Enumerating objects: 3928, done.
Counting objects: 100% (3928/3928), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3774/3774), done.
Writing objects: 100% (3928/3928), 4.54 MiB | 153.00 KiB/s, done.
Total 3928 (delta 735), 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): 10.15.3
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 10.15.3...
remote: Downloading and installing node 10.15.3...
remote: Using default npm version: 6.4.1
remote:
remote: -----> Installing dependencies
remote: Prebuild detected (node_modules already exists)
remote: Rebuilding any native modules
remote:
remote: > bcrypt#3.0.6 install /tmp/build_c2d2c217441a5d9a6c6d5e4798bcaba5/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#3.0.6 install: `node-pre-gyp install --fallback-to-build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the bcrypt#3.0.6 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.zomUn/_logs/2019-11-03T17_00_27_739Z-debug.log
remote:
remote: -----> Build failed
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
the error was due to node_modules so what i did was to run this code to my project terminal
$echo "node_modules" >> .gitignore
$git rm -r --cached node_modules
$git commit -am 'untracked node_modules'
and i managed to deploy my app to heroku
git rm -r --cached node_modules
git commit -m'Remove node_modules'

failure to deploy heroku app

Here is the error log:
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.0
remote: engines.npm (package.json): ~5.0.3
remote:
remote: Resolving node version ~6.11.0 via semver.io...
remote: Downloading and installing node 6.11.1...
remote: Resolving npm version ~5.0.3 via semver.io...
remote: Downloading and installing npm 5.0.4 (replacing version
3.10.10)...
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote: Prebuild detected (node_modules already exists)
remote: Rebuilding any native modules
remote: npm ERR! path
/tmp/build_9c402097d0e7567eccf5e236dc7f0959/node_modules/jade/bin/jade.js
remote: npm ERR! code ENOENT
remote: npm ERR! errno -2
remote: npm ERR! syscall chmod
remote: npm ERR! enoent ENOENT: no such file or directory, chmod
'/tmp/build_9c402097d0e7567eccf5e236dc7f0959/node_modules/jade/bin/jade.js'
remote: npm ERR! enoent This is related to npm not being able to
find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2017-07-16T02_45_14_132Z-
debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot
common issues here:
remote:
remote: Some possible problems:
remote:
remote: - node_modules checked into source control
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 pacific-harbor-25184.
remote:
To https://git.heroku.com/pacific-harbor-25184.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pacific-harbor-25184.git'
How can I get past this build error when deploying to heroku? (even though it works locally)
This is similar to a recent issue in cloudfoundry (but the same idea applies to heroku as well)
Male sure, in your local project, to ignore node_modules first:
echo 'node_modules' >> .gitignore
git rm -r --cached node_modules
git commit -m "ignore node_modules"
Then try your heroku deploy again.

(remote rejected) master -> master (pre-receive hook declined)

I'm having problems pushing to Heroku. This is happening on my first "Git push Heroku Master." I'm using Node JS.
The error I am getting is as follows:
Take a look at the entire error log below. Please let me know where I am going wrong while attempting to push my project to Heoku.
andrewleonardi:~/workspace/HelpMeRV/V1 (master) $ git push heroku master
Counting objects: 39, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (39/39), 11.80 KiB | 0 bytes/s, done.
Total 39 (delta 3), 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): 4.1.1
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Downloading and installing node 4.1.1...
remote: Using default npm version: 2.14.4
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new runtime signature)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote:
remote: > deasync#0.1.9 install /tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/locus/node_modules/deasync
remote: > node ./build.js
remote:
remote: `linux-x64-node-4` exists; testing
remote: Binary is fine; exiting
remote:
remote: > nodewebkit#0.11.6 postinstall /tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit
remote: > node scripts/install.js
remote:
remote: stream.js:74
remote: throw er; // Unhandled stream error in pipe.
remote: ^
remote:
remote: Error: invalid tar file
remote: at Extract.Parse._startEntry (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/lib/parse.js:145:13)
remote: at Extract.Parse._process (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/lib/parse.js:127:12)
remote: at BlockStream.<anonymous> (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/lib/parse.js:47:8)
remote: at emitOne (events.js:77:13)
remote: at BlockStream.emit (events.js:169:7)
remote: at BlockStream._emitChunk (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/block-stream/block-stream.js:145:10)
remote: at BlockStream.resume (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/block-stream/block-stream.js:58:15)
remote: at Extract.Reader.resume (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/fstream/lib/reader.js:255:34)
remote: at DirWriter.<anonymous> (/tmp/build_7c427b7600b55b6ea32823b63fa7f741/node_modules/nodewebkit/node_modules/download/node_modules/decompress/node_modules/tar/lib/extract.js:57:8)
remote: at emitNone (events.js:67:13)
remote: npm ERR! Linux 3.13.0-112-generic
remote: npm ERR! argv "/tmp/build_7c427b7600b55b6ea32823b63fa7f741/.heroku/node/bin/node" "/tmp/build_7c427b7600b55b6ea32823b63fa7f741/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_7c427b7600b55b6ea32823b63fa7f741/.npmrc"
remote: npm ERR! node v4.1.1
remote: npm ERR! npm v2.14.4
remote: npm ERR! code ELIFECYCLE
remote:
remote: npm ERR! nodewebkit#0.11.6 postinstall: `node scripts/install.js`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the nodewebkit#0.11.6 postinstall script 'node scripts/install.js'.
remote: npm ERR! This is most likely a problem with the nodewebkit package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR! node scripts/install.js
remote: npm ERR! You can get their info via:
remote: npm ERR! npm owner ls nodewebkit
remote: npm ERR! There is likely additional logging output above.
remote:
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR! /tmp/build_7c427b7600b55b6ea32823b63fa7f741/npm-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 frozen-escarpment-22835.
remote:
To https://git.heroku.com/frozen-escarpment-22835.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/frozen-escarpment-22835.git'
Looking at the package there are a few other open issues with the same issue you are having.
However, you may want to checkout the big ATTENTION label in the readme and try updating to the latest renamed version and see if you have the same issue
ATTENTION
node-webkit was renamed to nw.js as of version 0.12.0. The new and
official installer for nw.js is now npm install nw and the repo is
located at github.com/nwjs/npm-installer
All future releases >= 0.12.0 will be released through nw.
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/new-cv-meker.git'
find this line in your code : Two different lockfiles found: package-lock.json and yarn.lock
And Delete Your yarn.lock file and also uninstall package

Resources