0

I made a portfolio with Reactjs and a little bit of nodejs to implement nodemailer, and now I'm trying to deploy to heroku but I'm getting this error: ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/dedaportfolio.git

I'm trying everthing but it seems nothing working, I did a lot of research around but nothing worked to me Here is the error when I'm trying to push to heroku

    Enumerating objects: 38099, done.
Counting objects: 100% (38099/38099), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28232/28232), done.
Writing objects: 100% (38099/38099), 98.10 MiB | 108.00 KiB/s, done.
Total 38099 (delta 8542), reused 38081 (delta 8535), pack-reused 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: -----> 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.15.0
remote:        engines.npm (package.json):   7.24.2
remote:
remote:        Resolving node version 16.15.0...
remote:        Downloading and installing node 16.15.0...
remote:        Bootstrapping npm 7.24.2 (replacing 8.5.5)...
remote:        npm 7.24.2 installed
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules (package.json)
remote:        
remote:        added 89 packages, and audited 90 packages in 8s
remote:
remote:        12 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        1 critical severity vulnerability
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:        Detected both "build" and "heroku-postbuild" scripts
remote:        Running heroku-postbuild
remote:        
remote:        > myportfolio@1.0.0 heroku-postbuild
remote:        > cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build
remote:
remote:        
remote:        up to date, audited 1466 packages in 3s
remote:
remote:        194 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        7 high 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:        added 64 packages, removed 188 packages, changed 281 packages, and audited 1342 packages in 27s
remote:
remote:        207 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:        > frontend@0.1.0 build
remote:        > react-scripts build
remote:
remote: sh: 1: react-scripts: Permission denied
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 dedaportfolio.
remote:
To https://git.heroku.com/dedaportfolio.git
 ! [remote rejected]   main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dedaportfolio.git'

this the package.json in the root of my project

{
  "name": "myportfolio",
  "version": "1.0.0",
  "engines": {
    "node": "16.15.0",
    "npm":"7.24.2"
  },
  "description": "",
  "main": "index.js",
  "scripts": {
    "client": "cd client && npm start",
    "server": "nodemon server.js",
    "build": "cd client && npm run build",
    "dev":"concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
    "start": "node server.js",
    "heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "dotenv": "^16.0.1",
    "express": "^4.18.1",
    "nodemailer": "^4.7.0"
  },
  "devDependencies": {
    "concurrently": "^7.3.0"
  }
}

This is my client package.json


{
  "name": "client",
  "version": "0.1.0",
  "engines": {
    "node": "16.15.0"
  },
  "private": true,
  "dependencies": {
    "@fortawesome/free-brands-svg-icons": "^6.1.2",
    "@fortawesome/free-solid-svg-icons": "^6.1.2",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^0.27.2",
    "bootstrap": "^5.2.0",
    "framer-motion": "^7.0.0",
    "react": "^18.2.0",
    "react-bootstrap": "^2.4.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.3.0",
    "react-scripts": "^5.0.1",
    "react-scroll": "^1.8.7",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
Dedaldino
  • 21
  • 3
  • 1
    Please add your `client/package.json` to your question. – ChrisGPT was on strike Aug 05 '22 at 14:25
  • i have never tried to use single repo or heroku server to run/deploy both node & react on single server. Usually i would split it in 2 repositories/servers. Or have only backend to render with templating engines. But i read there is a way to try what you are trying - https://stackoverflow.com/questions/45997828/heroku-how-to-deploy-a-node-app-with-client-and-server-running-on-different-por – Stefan Aug 05 '22 at 15:51
  • @Chris, there it is – Dedaldino Aug 05 '22 at 18:00

1 Answers1

0

The final three messages here:

To https://git.heroku.com/dedaportfolio.git
 ! [remote rejected]   main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dedaportfolio.git'

are from Git itself and are simply a summary of the fact that Heroku (not Git) didn't like your code. Ignore them entirely as they add no information whatsoever; pay attention only to the remote:-prefixed lines. Git relays these lines to you whenever Heroku tells you why it does not like your code.

The remaining problems are all specific to either Heroku or your code. In this case, the errors come from npm, which is noting:

high severity vulnerabilities

which you should fix because security vulnerabilities are bad, but most importantly, from the next step in the build process:

sh: 1: react-scripts: Permission denied

which simply means that your react-scripts in the stuff you're deploying is wrong, so have a look at that.

torek
  • 448,244
  • 59
  • 642
  • 775
  • I got your point, but how can I do that? I'm stuck at this for 2 days – Dedaldino Aug 05 '22 at 18:52
  • Check the permissions on your `react-scripts` file, and check to see if it starts with something that would make it executable (e.g., `#! /bin/sh` or whatever interpreter is supposed to run it). – torek Aug 05 '22 at 22:17