Getting Problem whlie deploying my nodejs server in heruku - node.js

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'

Related

unable to perform git push in heroku

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

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.

Trouble deploying to Heroku, module can't resolve

Been trying all day to deploy this. Nothing is working. Ran through the entire node troubleshooter link, everything checks out. The where it says cant resolve module, My code is running fine on all severs and can't find the tmp folder, anywhere. I've only been coding a month. Sorry if this is stupid, but I'd appreciate some help.
Matt#DESKTOP-QFMSSDA MINGW64 ~/Desktop/momma-ecommerce (main)
$ git push heroku main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 442 bytes | 442.00 KiB/s, done.
Total 4 (delta 3), 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_PRODUCTION=false
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.13.2
remote: engines.npm (package.json): 8.1.2
remote:
remote: Resolving node version 16.13.2...
remote: Downloading and installing node 16.13.2...
remote: npm 8.1.2 already installed with node
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 252 packages, and audited 253 packages in 9s
remote:
remote: 24 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > momma-art-sell#1.0.0 heroku-postbuild
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --
prefix frontend
remote:
remote:
remote: added 1445 packages, and audited 1446 packages in 24s
remote:
remote: 171 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 7 moderate severity vulnerabilities
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: > frontend#0.1.0 build
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: Module not found: Error: Can't resolve '../components/Message' in
'/tmp/build_4ecd4ad3/frontend/src/screens'
remote:
remote:
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 mjthomasart.
remote:
To https://git.heroku.com/mjthomasart.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mjthomasart.git'``

How to resolve "Unable to download node 14.18.0" when deploying an Ember.js app to Heroku?

I encountered the error mentioned in the Title.
I have referred to a few relevant Heroku articles and tried their suggested changes including specifying the exact version of Node.js, Yarn, or npm that I'm using locally , but that still didn't work.
Here's the relevant sections extracted from my package.json:
"engines": {
"node": "14.18.0",
"npm": "6.14.15",
"yarn": "1.19.1"
},
"ember": {
"edition": "octane"
}
Here's the deployment log:
Enumerating objects: 1134, done.
Counting objects: 100% (1134/1134), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1027/1027), done.
Writing objects: 100% (1134/1134), 309.32 KiB | 2.64 MiB/s, done.
Total 1134 (delta 581), 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: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/emberjs.tgz
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_PRODUCTION=false
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): 14.18.0
remote: engines.npm (package.json): 6.14.15
remote:
remote: Downloading and installing node 14.18.0...
remote: Unable to download node 14.18.0; does it exist?
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: -----> Failed trying to compile heroku/nodejs-v98
remote: ! Push rejected, failed to compile emberjs app.
remote:
remote: ! Push failed
remote: !
According to this Heroku page, versions 12.x, 14.x, and 16.x are supported.
When such version numbers are literally specified in package.json file, during the Heroku build process, those will be resolved to the latest patch version, e.g. 12.22.7, 14.18.1, and 16.13.0 respectively as of the time of writing.
Somehow Heroku was unable to download the latest version of every major series.
In my original question, I used version 14.18.0 in my local and that version was specified in package.json. It appears that Heroku was also not able to download that version.
I double checked this Heroku Help page and noticed version 12.16.3 is given in the example when illustrating how to compare Node and npm versions. I updated my package.json to use 12.16.3 and retried the the deployment and it was successful.
I tried to search but unfortunately I couldn't find any Heroku Help page that specifies the exact Node.js version numbers that they support.

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