0

Update: I've learned more about the role of the Procfile and how Heroku will use the "Start" script if there is no Procfile present, but I am still getting the same error when deploying.

I'm trying to deploy a MERN application on Heroku through the GitHub deployment method option on the Heroku website. I know that the Heroku CLI is probably better, but I'm trying to not overcomplicate things for myself at the moment and using their option for GitHub should work too. Here is my build log:

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.17.5...
       Using default npm version: 6.14.14
       
-----> Restoring cache
       - node_modules
       
-----> Installing dependencies
       Installing node modules
       added 83 packages in 2.675s
       
-----> Build
       
-----> Caching build
       - node_modules
       
-----> Pruning devDependencies
       audited 83 packages in 1.019s
       
       4 packages are looking for funding
         run `npm fund` for details
       
       found 0 vulnerabilities
       
       
-----> Build succeeded!
-----> Discovering process types
       Default types for buildpack -> web
-----> Compressing...
       Done: 35.6M
-----> Launching...
       Released v7
       https://react-node-database.herokuapp.com/ deployed to Heroku

The GitHub repository that I'm using is here:
https://github.com/phershbe/nodeandreactwithdatabase

The page that I'm getting says "Internal Server Error":
https://react-node-database.herokuapp.com/

The application works for me on my localhost of course. I've tried searching for similar questions on here and YouTube and Google but haven't found what I'm searching for obviously. Any solutions or recommendations would be greatly appreciated.

phershbe
  • 169
  • 4
  • 12

2 Answers2

0

Inside your package.json you must enter the command "start": "node server.js"

enter image description here

alexisDev
  • 96
  • 2
0

The problem is in your package.json file. You still using the default configuration when you did the command npm init.

Change the test script here

scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  }

To this

scripts": {
    "start": "node server.js"
  }

Now redeploy.

Innextinit
  • 117
  • 11
  • Thank you. I changed that and am having the same problem though. You can check it in my GitHub repository: https://github.com/phershbe/nodeandreactwithdatabase – phershbe Aug 31 '21 at 14:46
  • From what I understand, the Procfile takes care of that too. – phershbe Aug 31 '21 at 14:51
  • You are making use of react for your frontend. The problem you would here is that the build pack that is going to be used for this project is that of NodeJs and it would not work for that of the frontend react app – Innextinit Sep 01 '21 at 16:26
  • I would advise you have your frontend react app hosted differently from that of the backend. So for the deployment of your frontend, the default build pack `Heroku` would use is that of NodeJs, so this https://stackoverflow.com/a/68992661/16471757 would help in going about deployment of your frontend. You can now use `axios` to make request your backend. – Innextinit Sep 01 '21 at 16:31