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

305
Vistas
Is there a difference between env / ENV and PORT / port in NodeJs?

I'm new to Node.js and recently saw the following code used for the port connection :

process.ENV.PORT

And have also seen someone use process.env.PORT and even process.env.port. Now as far as I know JS variables and properties are case sensitives, so how come people are using different versions?

My IDE seems to recommend everything in lower case, so I'm curious, what I wish to know is :

  • whether all of the above are valid.

  • Why are they valid (JS is case sensitive)

  • and is there a difference between any of them

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

0

Having process.env.PORT or process.env.port is up to you. You chose to call whatever you want your variable. And it is process.env in lowercase in Node's official doc. Here is the link if you wanna read it.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Answering your questions:

whether all of the above are valid. no, they are not. process.ENV is not the same as process.env. In fact the built-in process does not have an ENV property; so it is not valid unless you create a process.ENV property (wichi is a very bad idea btw) But in windows process.env.PORT and process.env.port they are interchangeably valid

Why are they valid ? because eventhough JS is case sensitive, the standard process.env property is, under windows, for cross-platform compatibility.

is there a difference between any of them ? .env and .ENV are different totally different .ENV does not even exist; on windows between .port and .PORT there is not any practical difference.

about 4 years ago · Juan Pablo Isaza Denunciar

0

process.env is an object created by Node.js environment which contains some accessible internal keys and can be extended / edited programmatically. It means you can define or edit any properties you want.
So...

whether all of the above are valid
Both of them are valid because any key is valid (even process.env.notReal), which one to use is only your choice.

Why are they valid (JS is case sensitive)
Sure, JS is case sensitive, so process.env.PORT is not the same as process.env.port - they are two different properties. Variable naming policy is up to you.

and is there a difference between any of them
I guess you already got the answer, it's just a code style.

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