avantdev
avantdev

Reputation: 2724

Deploy MERN on heroku cause unexpectable errors

I have a MERN stack project - it is based on NodeJS(Express), ReactJS and using mLab for DB, webpack for resource maintanence.

At the beginning, I just use ReactJS, after a while I add backend for api.

When I use only ReactJS, deploying on heroku was very successful. But when I mix up NodeJS & ReactJS & Webpack & mLab, deploying on heroku succeeded sometimes and failed most of times.

So I need to deploy several times.

What's wrong with me?

Upvotes: 0

Views: 195

Answers (1)

Dan Hook
Dan Hook

Reputation: 21

First, do you have scripts set up in your outer package.json? Mine looks something like this

  "engines": {
    "node": "9.9.0",
    "yarn": "1.5.1"
 },
 "dependencies": {
    "bcrypt": "^2.0.1",
    "body-parser": "^1.18.2",
    "cors": "^2.8.4",
    "dotenv": "^5.0.1",
    "express": "^4.16.3",
    "express-jwt": "^5.3.1",
    "helmet": "^3.12.0",
    "jsonwebtoken": "^8.2.1",
    "mongodb": "^3.0.7",
    "mongoose": "^5.0.17",
    "passport": "^0.4.0",
    "passport-facebook": "^2.1.1",
    "passport-google-oauth": "^1.0.0",
    "passport-local": "^1.0.0"
  },
   "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node backend-card-game/server.js",
        "heroku-postbuild": "cd card-game && yarn install && yarn build"
    },
...

Secondly, is your backend pointing the the right db url? in terminal type

heroku config:get MONGODB_URI

make sure your backend is pointing to that url, otherwise if neither of those help then I would need to see the error message.

Upvotes: 1

Related Questions