Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda