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

244
Vistas
How can I set process.env.VAR on my local machine using bash/zsh script?

and what is this command actually doing?

export VAR="My permanent variable"

I used this and was able to see that it was set by doing a:

printenv VAR

However, when I console.log(process.env) in Node I can not find it. Here is the ouptut:

{
  USER: 'c',
  __CFBundleIdentifier: 'com.sublimetext.4',
  COMMAND_MODE: 'unix2003',
  LOGNAME: 'c',
  PATH: '/Applications/Sublime Text.app/Contents/SharedSupport/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin',
  SSH_AUTH_SOCK: '/private/tmp/com.apple.launchd.jc2uZOHY77/Listeners',
  SHELL: '/bin/zsh',
  HOME: '/Users/c',
  __CF_USER_TEXT_ENCODING: '0x1F5:0x0:0x0',
  TMPDIR: '/var/folders/tx/zyf0hzln2rn97yd61x50y9l80000gn/T/',
  XPC_SERVICE_NAME: '0',
  XPC_FLAGS: '0x0',
  LC_CTYPE: 'UTF-8',
  SSL_CERT_FILE: '/Applications/Sublime Text.app/Contents/MacOS/Lib/python3/certifi/cacert.pem',
  OLDPWD: '/'
}

I would like to set the process.env.VAR directly in the bash/zsh ( I am using zshell.) and have access to it in my Node code.

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

0

It set env variable, however not persistent manner.

If you do

export MY_VAR=123 && node index.js

Assuming index.js will have console.log(process.env) you will get the output. But in different terminal windows it won't be visible/shared. To achieve that you need to add export VAR=value in .bashrc file and reload the content. (It means every time a new terminal is open it will set that value)

Since you use zshell it will be .zshrc.

  1. Open/edit nano ~/.zshrc
  2. Add export YOUR_VAR=your_value
  3. Save
  4. Reload by running zsh or reopen terminal

Here are more details on how to do it for zsh. link

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