Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!