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

223
Vistas
Why I get UNDEFINED from ENVIRONMENT VARIABLE in REACT App?

Unfortunately, it's a pretty simple question, but I can't find the answer.

Don't have an access to environment variables in some file.

I use create-react-app (^16.11.0)

  • file .env in the root folder near package.json
  • variable declared as REACT_APP_API=http://localhost:4000
  • call variable as process.env.REACT_APP_API
  • the server has been restarted many times

I have an access to the variable in some folder but in another don't.

below link to files structure

workflow structure

Thanks a lot!

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

0

THE PROBLEM WAS FOUND! As often happens, the reason is funny.

When typing process.env.REACT_APP_API, my IDE automaticlly added an import at the top of the file

import process from "process"; 

That's why i can't access to process.env. in one specific file.

Import removed, problem solved

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