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

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

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 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