Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

408
Vistas
Heroku - Deploy in Dev or Production

I have an express API which I am hosting on Heroku. I created two projects: one project points at my Master Branch (Prod) and the other at my Development branch (Dev).

I have two scripts in my package JSON:

  "scripts": {
    "devStart": "export NODE_ENV=development && nodemon server.js",
    "start": "export NODE_ENV=production && node server.js"
  }

How can I make it so, that the development branch runs "DevStart" and Master runs "start". Currently Prod is working fine as node start is the default script.

I understand I can put commands in my procfile, however since both Dev and Prod use the same codebase, I would need to change this with each commit. Is there a dynamic way to do this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ok, This might not be the correct way but here is how I did it.

I seen you can set the NODE_ENV variable for the Heroku app using terminal:

heroku config:set NODE_ENV=development --app {app-name}

My package JSON though was overwriting this when the app deployed.

  "scripts": {
    "devStart": "export NODE_ENV=development && nodemon server.js",
    "start": "export NODE_ENV=production && node server.js"
  },

I changed it to:

  "scripts": {
    "localStart": "export NODE_ENV=development && nodemon server.js",
    "start": "node server.js"
  },

This now resolves the problem. No need for the Procfile or to setup environment variables within Heroku.

On Heroku I have two apps, one for production which I don't change the NODE_ENV variable as it defaults to production, and another for Development, which I do change the NODE_ENV variable to 'Development'.

Each app is hooked up to a different branch within the same code base ( Development(Development) & Master(Production) ). Any deploys to either branch will cause a rebuild using the correct NODE_ENV variable for each respective branch.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda