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

122
Vistas
How to configure React package.json file to use different .env files for different builds with dotenv

I am using dotenv with create-react-app. I have three different .env files in my root directory. I have .env .env.develop .env.stage

I want the variables in these file to map as described below

.env                   -> production site

.env.develop           -> local development

.env.stage             -> stage site

I am guessing that I have to make some changes to the scripts object in the package.json file but I am not sure of what to exactly do.

My current package.json is as follows

{
  "name": "web_app",
  "version": "0.1.0",
  "private": true,
  "homepage": "",
  "devDependencies": {... },
  "dependencies": {... },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

So I would like to know how to tell react to use the correct .env file for each environment.

Thanks in advance to anyone who can help

about 4 years ago · Santiago Gelvez
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