Heroku git push heroku master runs cd client && npm run build non stop

Viewed 445

So i got a problem.

I try to deploy my MERN application to Heroku.

So when i do git push heroku master it runs okay but then it runs in a loop cd client && npm run build.

I have no idea why.

Does anyone of you know?

Here is my node:

const PORT = process.env.PORT || 8080;

mongoose.connect('my mongo db', {useNewUrlParser: true})

app.use(passport.initialize());
app.use(passport.session());
app.use(session({
    resave: false,
    saveUninitialized: false,
    secret: 'secret here',
    store: new MongoStore({ mongooseConnection: mongoose.connection })
}))

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

app.use('/', indexRouter);
app.use('/authentication', usersRouter);

if (process.env.NODE_ENV === 'production') {
    app.use(express.static('client/build'))
}

app.listen(PORT);

module.exports = app

And here is my package:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon app.js",
    "build": "cd client && npm run build",
    "install-client": "cd client && npm install",
    "heroku-postbuild": "npm run install-client && npm run build"
  },

I only posted the code require and not my whole code if something you need is missing let me know!

-Thanks

2 Answers

I had the same problem, I had an inner create-react-app as a client folder. For some reason the client folder didn't made to the master branch after pushing the whole project, included the server. After deleting the .git folder from the client folder the problem solved.

I had this problem, another .git folder in the client folder. delete that folder use commands : Heroku plugins: install, Heroku-builds Heroku builds: cancel, Heroku restart push in Heroku again it will work fine.

Related