I have an app create in Heroku with a free account.
It's my first Nextjs app. I have created a few react apps and deployed them successfully using the https://github.com/mars/create-react-app-buildpack buildpack,
I am attempting to use the https://github.com/mars/heroku-nextjs.git buildpack. I continue to get the following error when pushing and attempting to build:
Enumerating objects: 695, done.
Counting objects: 100% (695/695), done.
Delta compression using up to 4 threads
Compressing objects: 100% (638/638), done.
Writing objects: 100% (695/695), 406.94 KiB | 1.78 MiB/s, done.
Total 695 (delta 388), reused 20 (delta 13)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: https://github.com/mars/heroku-nextjs.git
remote: -----> App not compatible with buildpack: https://github.com/mars/heroku-nextjs.git
remote: bash: /tmp/codon/tmp/buildpacks/cc998aa50faebde1ea66717737aec22c884e4936/bin/detect: No such file or directory
remote:
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: b1006412ec2d412e7edaed795dcbceff02d98f82
remote: !
remote: ! We have detected that you have triggered a build from source code with version b1006412ec2d412e7edaed795dcbceff02d98f82
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 gurnzapp-test.
I have read everything I can find online about this. The most common error that is in the github issues is that people put package.json in a subdirectory. My package.json is in the root. My project is set up correctly as far as I can tell.
I have tried:
pushing from the main branch directly to heroku's main branch.
pushing from a local development branch in the git push heroku development:main format.
removeing package-lock.json.
Using another buildpack: https://github.com/ryanbahniuk/nextjs-buildpack.git
I'm at a loss as to why I'd have issues building. Any help would be amazing :D
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: https://github.com/mars/heroku-nextjs.git
remote: -----> App not compatible with buildpack: https://github.com/mars/heroku-nextjs.git
remote: bash: /tmp/codon/tmp/buildpacks/cc998aa50faebde1ea66717737aec22c884e4936/bin/detect: No such file or directory
remote:
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
It says App not compatible with buildpack.
This is not a buildpack:
https://github.com/mars/heroku-nextjs
These are buildpacks:
https://github.com/mars/create-react-app-buildpack
https://github.com/heroku/heroku-buildpack-nodejs
You can ignore this buildpack. It does nothing.
https://github.com/ryanbahniuk/nextjs-buildpack
Read how buildpacks work here:
https://devcenter.heroku.com/articles/buildpacks
Related
This question already has answers here:
How to deploy reactapp with heroku-22?
(3 answers)
git, Heroku: pre-receive hook declined
(25 answers)
Closed 20 days ago.
I am trying to see how to use React on a Heroku app for the first time.
I followed these tutorials:
https://www.bacancytechnology.com/blog/deploy-react-app-on-heroku
https://stackabuse.com/how-to-deploy-a-react-app-to-heroku/
By the end I hit the issue below when running the command: git push heroku main
I did two trials and had the same problem each time. I do not remember having seen this before. What is the way to handle the situation?
remote: Verifying deploy...
remote:
remote: ! Push rejected to testapp.
remote:
To https://git.heroku.com/testapp.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/testapp.git'
me#My-MacBook testapp %
For more details; this is the complete result of running the git push heroku main command:
me#My-MacBook testapp % git push heroku main
Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 8 threads
Compressing objects: 100% (22/22), done.
Writing objects: 100% (22/22), 307.67 KiB | 8.10 MiB/s, done.
Total 22 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: mars/create-react-app
remote: -----> React.js (create-react-app) multi app detected
remote:
remote: =====! create-react-app-buildpack has reached end-of-life 🌅
remote: This build may succeed, but the buildpack is no longer maintained.
remote: On the Heroku-22 stack and beyond, this may fail to build at all.
remote:
remote: Please consider migrating to https://nextjs.org or https://remix.run to develop React apps which are deployable using Heroku's Node.js buildpack https://github.com/heroku/heroku-buildpack-nodejs, or you may develop your own create-react-app deployment with Node.js and Nginx buildpacks.
remote:
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-multi.git
remote: =====> Detected Framework: Multipack
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
remote: =====> Detected Framework: Node.js
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): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 18.x...
remote: Downloading and installing node 18.13.0...
remote: Using default npm version: 8.19.3
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 1470 packages, and audited 1471 packages in 19s
remote:
remote: 231 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 6 high severity vulnerabilities
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: > testapp#0.1.0 build
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Compiled successfully.
remote:
remote: File sizes after gzip:
remote:
remote: 46.6 kB build/static/js/main.c9d4c383.js
remote: 1.78 kB build/static/js/787.49a3df42.chunk.js
remote: 541 B build/static/css/main.073c9b0a.css
remote:
remote: The project was built assuming it is hosted at /.
remote: You can control this with the homepage field in your package.json.
remote:
remote: The build folder is ready to be deployed.
remote: You may serve it with a static server:
remote:
remote: npm install -g serve
remote: serve -s build
remote:
remote: Find out more about deployment here:
remote:
remote: https://cra.link/deployment
remote:
remote:
remote: -----> Caching build
remote: - npm cache
remote:
remote: -----> Pruning devDependencies
remote:
remote: up to date, audited 1471 packages in 4s
remote:
remote: 231 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 6 high severity vulnerabilities
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 succeeded!
remote: =====> Downloading Buildpack: https://github.com/mars/create-react-app-inner-buildpack.git#v9.0.0
remote: =====> Detected Framework: React.js (create-react-app)
remote: Writing `static.json` to support create-react-app
remote: Enabling runtime environment variables
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-static.git#21c1f5175186b70cf247384fd0bf922504b419be
remote: =====> Detected Framework: Static HTML
remote: Stack heroku-22 is not supported!
remote: ! Push rejected, failed to compile React.js (create-react-app) multi app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: f609d0c54516882f24faf2a1b4fcad975cc76b04
remote: !
remote: ! We have detected that you have triggered a build from source code with version f609d0c54516882f24faf2a1b4fcad975cc76b04
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 testapp.
remote:
To https://git.heroku.com/testapp.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/testapp.git'
me#My-MacBook testapp %
As your logs explain, this is not a git push issue but rather heroku version compatibility issue with react. I hope this helps,
https://stackoverflow.com/a/72743983/2699319
> pre-receive hook declined
indicates either that branch is protected from direct pushes OR you lack the permissions to push to that branch. If it's your own project, you can change this in the repository's settings. If it's a group/company project, you might want to ask around for permissions/access.
Since it is called main, I will assume the branch is important for the overall project. You might want to make a pull request then ask your peers to review and approve it.
Alternatively if you are testing this out in a sandbox environment by yourself, you can just force push
git push -f heroku main
I had deployed a website I am working which is a Reactjs Express App to Heroku. It has deployed for 3 weeks now. But after making some changes to app recently I am not able to push the code to heroku. I am encountering an error when doing a push.
$ git push heroku master
Enumerating objects: 912, done.
Counting objects: 100% (912/912), done.
Delta compression using up to 8 threads
Compressing objects: 100% (725/725), done.
Writing objects: 100% (742/742), 27.42 MiB | 2.69 MiB/s, done.
Total 742 (delta 160), reused 30 (delta 8), 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: USE_YARN_CACHE=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=false
remote:
remote: -----> Build failed
remote: ! The 'yarnPath' could not be read from the 'yarnrc.yml' file
remote:
remote: It looks like 'yarnrc.yml' is missing the 'yarnPath' value, which is needed
remote: to identify the location of yarn for this build.
remote:
remote: To regenerate 'yarnrc.yml' with the 'yarnPath' value set, make sure Yarn 2
remote: is installed on your local machine and set the version in your project
remote: directory with:
remote:
remote: $ yarn set version berry
remote:
remote: Read more at the Yarn docs: https://yarnpkg.com/getting-started/install#per-project-install
remote:
remote: https://devcenter.heroku.com/articles/nodejs-support
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: 21afbb1f965651a191a2a03c3d0047685d8c76fc
remote: !
remote: ! We have detected that you have triggered a build from source code with version 21afbb1f965651a191a2a03c3d0047685d8c76fc
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 jithin-career.
remote:
To https://git.heroku.com/jithin-career.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/jithin-career.git'
I have been trying to find a solution to this for some time. Some of the solutions which was mentioned didn't work for me. Can anyone please help me this issue?
I had a similar problem.
Here is the solution.
locally, run the following command
yarn set version berry
activate Zero-Install in .gitignore
.yarn/*
!.yarn/cache
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
or Deactivate Zero-Install
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn install and apply instllation.
Commit all changes to git repogitory.
git push heroku main
For more information, please refer to the official manual page.
https://devcenter.heroku.com/articles/migrating-to-yarn-2#make-changes-to-source-code
It looks like it's getting something because when I go to my website/users(my backend has users and games) it gives me an empty array for users and permission denied for games(which it should be there are validations). But it just doesn't work at all and I'm new to this I'm confused about where I even troubleshoot this?
picture of the terminal in order 1
picture of the terminal in order 2
picture of the terminal in order 3
picture of the terminal in order 4
picture of the terminal in order 5
/usersOnWebsite
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ sudo service postgresql start
* Starting PostgreSQL 12 database server [ OK ]
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ whoami
zvallarino
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ heroku create flyhome010922
Creating ⬢ flyhome010922... done
https://flyhome010922.herokuapp.com/ | https://git.heroku.com/flyhome010922.git
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ heroku buildpacks:add heroku/nodejs --index 1
Buildpack added. Next release on flyhome010922 will use heroku/nodejs.
Run git push heroku main to create a new release using this buildpack.
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ heroku buildpacks:add heroku/ruby --index 2
Buildpack added. Next release on flyhome010922 will use:
1. heroku/nodejs
2. heroku/ruby
Run git push heroku main to create a new release using these buildpacks.
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ git add .
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ git commit -m "I have faith this time"
On branch main
nothing to commit, working tree clean
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ git push heroku main
Enumerating objects: 980, done.
Counting objects: 100% (980/980), done.
Delta compression using up to 12 threads
Compressing objects: 100% (493/493), done.
Writing objects: 100% (980/980), 473.44 KiB | 7.07 MiB/s, done.
Total 980 (delta 701), reused 561 (delta 472), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpacks:
remote: 1. heroku/nodejs
remote: 2. heroku/ruby
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): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 14.x...
remote: Downloading and installing node 14.18.2...
remote: Using default npm version: 6.14.15
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote: added 0 packages in 0.027s
remote:
remote: -----> Build
remote:
remote: -----> Caching build
remote: - node_modules (nothing to cache)
remote:
remote: -----> Pruning devDependencies
remote: up to date in 0.456s
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build succeeded!
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.2.33
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.7.4
remote: -----> Installing dependencies using bundler 2.2.33
remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote: Fetching gem metadata from https://rubygems.org/..........
remote: Fetching rake 13.0.6
remote: Installing rake 13.0.6
remote: Fetching concurrent-ruby 1.1.9
remote: Fetching minitest 5.15.0
remote: Fetching zeitwerk 2.5.1
remote: Fetching builder 3.2.4
remote: Installing zeitwerk 2.5.1
remote: Installing builder 3.2.4
remote: Installing minitest 5.15.0
remote: Fetching erubi 1.10.0
remote: Installing concurrent-ruby 1.1.9
remote: Installing erubi 1.10.0
remote: Fetching racc 1.6.0
remote: Fetching crass 1.0.6
remote: Fetching rack 2.2.3
remote: Installing racc 1.6.0 with native extensions
remote: Installing rack 2.2.3
remote: Installing crass 1.0.6
remote: Fetching nio4r 2.5.8
remote: Fetching websocket-extensions 0.1.5
remote: Installing nio4r 2.5.8 with native extensions
remote: Installing websocket-extensions 0.1.5
remote: Fetching marcel 1.0.2
remote: Fetching mini_mime 1.1.2
remote: Installing marcel 1.0.2
remote: Installing mini_mime 1.1.2
remote: Fetching jsonapi-renderer 0.2.2
remote: Fetching bcrypt 3.1.16
remote: Installing jsonapi-renderer 0.2.2
remote: Installing bcrypt 3.1.16 with native extensions
remote: Fetching msgpack 1.4.2
remote: Installing msgpack 1.4.2 with native extensions
remote: Using bundler 2.2.33
remote: Fetching method_source 1.0.0
remote: Installing method_source 1.0.0
remote: Fetching pg 1.2.3
remote: Installing pg 1.2.3 with native extensions
remote: Fetching thor 1.1.0
remote: Installing thor 1.1.0
remote: Fetching rack-test 1.1.0
remote: Installing rack-test 1.1.0
remote: Fetching websocket-driver 0.7.5
remote: Installing websocket-driver 0.7.5 with native extensions
remote: Fetching i18n 1.8.11
remote: Installing i18n 1.8.11
remote: Fetching tzinfo 2.0.4
remote: Installing tzinfo 2.0.4
remote: Fetching sprockets 4.0.2
remote: Installing sprockets 4.0.2
remote: Fetching mail 2.7.1
remote: Installing mail 2.7.1
remote: Fetching nokogiri 1.12.5 (x86_64-linux)
remote: Installing nokogiri 1.12.5 (x86_64-linux)
remote: Fetching puma 5.5.2
remote: Installing puma 5.5.2 with native extensions
remote: Fetching activesupport 6.1.4.3
remote: Installing activesupport 6.1.4.3
remote: Fetching loofah 2.13.0
remote: Installing loofah 2.13.0
remote: Fetching bootsnap 1.9.3
remote: Installing bootsnap 1.9.3 with native extensions
remote: Fetching rails-dom-testing 2.0.3
remote: Installing rails-dom-testing 2.0.3
remote: Fetching globalid 1.0.0
remote: Installing globalid 1.0.0
remote: Fetching activemodel 6.1.4.3
remote: Installing activemodel 6.1.4.3
remote: Fetching case_transform 0.2
remote: Installing case_transform 0.2
remote: Fetching rails-html-sanitizer 1.4.2
remote: Installing rails-html-sanitizer 1.4.2
remote: Fetching activejob 6.1.4.3
remote: Installing activejob 6.1.4.3
remote: Fetching activerecord 6.1.4.3
remote: Installing activerecord 6.1.4.3
remote: Fetching actionview 6.1.4.3
remote: Installing actionview 6.1.4.3
remote: Fetching actionpack 6.1.4.3
remote: Installing actionpack 6.1.4.3
remote: Fetching actioncable 6.1.4.3
remote: Fetching activestorage 6.1.4.3
remote: Installing activestorage 6.1.4.3
remote: Installing actioncable 6.1.4.3
remote: Fetching actionmailer 6.1.4.3
remote: Installing actionmailer 6.1.4.3
remote: Fetching active_model_serializers 0.10.12
remote: Installing active_model_serializers 0.10.12
remote: Fetching railties 6.1.4.3
remote: Installing railties 6.1.4.3
remote: Fetching sprockets-rails 3.4.2
remote: Installing sprockets-rails 3.4.2
remote: Fetching actionmailbox 6.1.4.3
remote: Installing actionmailbox 6.1.4.3
remote: Fetching actiontext 6.1.4.3
remote: Installing actiontext 6.1.4.3
remote: Fetching rails 6.1.4.3
remote: Installing rails 6.1.4.3
remote: Bundle complete! 10 Gemfile dependencies, 49 gems now installed.
remote: Gems in the groups 'development' and 'test' were not installed.
remote: Bundled gems are installed into `./vendor/bundle`
remote: Bundle completed (19.43s)
remote: Cleaning up the bundler cache.
remote: -----> Detecting rake tasks
remote: -----> Detecting rails configuration
remote:
remote: ###### WARNING:
remote:
remote: There is a more recent Ruby version available for you to use:
remote:
remote: 2.7.5
remote:
remote: The latest version will include security and bug fixes. We always recommend
remote: running the latest version of your minor release.
remote:
remote: Please upgrade your Ruby version.
remote:
remote: For all available Ruby versions see:
remote: https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote:
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> release, web
remote: Default types for buildpack -> console, rake
remote:
remote: -----> Compressing...
remote: Done: 62.3M
remote: -----> Launching...
remote: ! Release command declared: this new release will not be available until the command succeeds.
remote: Released v6
remote: https://flyhome010922.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
remote: Running release command...
remote:
remote: I, [2022-01-09T18:38:11.135797 #16] INFO -- : Migrating to CreateUsers (20211215192349)
remote: == 20211215192349 CreateUsers: migrating ======================================
remote: -- create_table(:users)
remote: -> 0.0131s
remote: == 20211215192349 CreateUsers: migrated (0.0132s) =============================
remote:
remote: I, [2022-01-09T18:38:11.163117 #16] INFO -- : Migrating to CreateGames (20211216234121)
remote: == 20211216234121 CreateGames: migrating ======================================
remote: -- create_table(:games)
remote: -> 0.0105s
remote: == 20211216234121 CreateGames: migrated (0.0105s) =============================
remote:
remote: I, [2022-01-09T18:38:11.180094 #16] INFO -- : Migrating to CreateGameTables (20211216234129)
remote: == 20211216234129 CreateGameTables: migrating =================================
remote: -- create_table(:game_tables)
remote: -> 0.0202s
remote: == 20211216234129 CreateGameTables: migrated (0.0202s) ========================
remote:
remote: I, [2022-01-09T18:38:11.206719 #16] INFO -- : Migrating to CreateHighscores (20211216234153)
remote: == 20211216234153 CreateHighscores: migrating =================================
remote: -- create_table(:highscores)
remote: -> 0.0201s
remote: == 20211216234153 CreateHighscores: migrated (0.0202s) ========================
remote:
remote: Waiting for release.... done.
To https://git.heroku.com/flyhome010922.git
* [new branch] main -> main
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ heroku run rails db:migrate
Running rails db:migrate on ⬢ flyhome010922... up, run.1737 (Free)
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ heroku run rails db:seed
Running rails db:seed on ⬢ flyhome010922... up, run.6674 (Free)
"done seeding yo"
zvallarino#DESKTOP-K5VQL0B:~/Development/flyhome/flyhome$ heroku open
â–¸ Error opening web browser.
â–¸ Error: Exited with code 3
â–¸
â–¸ Manually visit https://flyhome010922.herokuapp.com/ in your browser.
Resolution was to add the scripts
"engines": {
"node": "16.x"
},
"scripts": {
"build": "npm install --prefix client && npm run build --prefix client",
"clean": "rm -rf public",
"deploy": "cp -a client/build/. public/",
"heroku-postbuild": "npm run clean && npm run build && npm run deploy"
}
I have created a web application which uses technology like Node.js and React.js. Now I created it and now I am trying to push this app to Heroku and when I do that it shows some error persistently, I tried in very different numerous ways but it doesn't work. Error log is something like this:
Counting objects: 25717, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16046/16046), done.
Writing objects: 100% (25717/25717), 26.05 MiB | 59.00 KiB/s, done.
Total 25717 (delta 8710), reused 25548 (delta 8617)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote: parse error: Expected another key-value pair at line 12, column 3
remote: ! Unable to parse package.json
remote:
remote:
remote: -----> Build failed
remote: parse error: Expected another key-value pair at line 12, column 3
remote: parse error: Expected another key-value pair at line 12, column 3
remote: parse error: Expected another key-value pair at line 12, column 3
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 optioncapital.
remote:
To https://git.heroku.com/optioncapital.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/optioncapital.git'
I am not understanding weather procfile and all are required or not, but I am learning through one online course and that person isn't doing anything like that.... Please tell me how to resolve this issue...
Looking at this error:
remote: parse error: Expected another key-value pair at line 12, column 3
remote: ! Unable to parse package.json
It looks like you are having an issue with the package.json
===========================================
Do this
Delete 'node_modules' folder
npm cache clean
npm update
I am trying to host the react app in heroku...
I have created the app using create-react-app..And follow the following methods in hosting...
git init
heroku create $APP_NAME --buildpack https://github.com/mars/create-react-app-buildpack.git
git add .
git commit -m "Start with create-react-app"
git push heroku master
heroku open
But when I am trying to push the app to heroku it returns the following error...
remote: - htmlparser.js:235 new HTMLParser
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[html-minifier]/src/htmlparser.js:2 35:13
remote:
remote: - htmlminifier.js:946 minify
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[html-minifier]/src/htmlminifier.js :946:3
remote:
remote: - htmlminifier.js:1299 exports.minify
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[html-minifier]/src/htmlminifier.js :1299:10
remote:
remote: - index.js:296
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[html-webpack-plugin]/index.js:296: 16
remote:
remote: - util.js:16 tryCatcher
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/util.js:16:23
remote: - promise.js:512 Promise._settlePromiseFromHandler
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:51 2:31
remote:
remote: - promise.js:569 Promise._settlePromise
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:56 9:18
remote:
remote: - promise.js:614 Promise._settlePromise0
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:61 4:10
remote:
remote: - promise.js:693 Promise._settlePromises
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:69 3:18
remote:
remote: - async.js:133 Async._drainQueue
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/async.js:133: 16
remote:
remote: - async.js:143 Async._drainQueues
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/async.js:143: 10
remote:
remote: - async.js:17 Immediate.Async.drainQueues
remote: [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/async.js:17:1 4
How can I resolve this issue?
I just cloned your repo and tried npm install + npm run build. I found that npm run build fails locally. So, this is an error with the code, not with Heroku deployment.
The failure is from HTMLParser, so I looked at the public/index.html and found a heavily customized template.
To check if that public/index.html content was the problem, I replaced it with the default create-react-app HTML template code. Then, npm run build completed successfully.
So, it seems there is a problem with the validity of the HTML in your public/index.html which breaks create-react-app's template engine. I suggest running it through an HTML validator to find problems, or manually breaking the template into smaller testable pieces until you find the part that causes the build error.