Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:58:28+00:00 2026-06-04T14:58:28+00:00

I am on Ubuntu 12.04 and I’m just learning about environment variables. I am

  • 0

I am on Ubuntu 12.04 and I’m just learning about environment variables. I am trying to read a custom variable from within my application but it always shows up as undefined. Here is the code of my test app:

// app.js

console.log('Value: ' + process.env.NODE_ENV);

If I run the following commands you will see that the variable has a value:

$ NODE_ENV=production
$ echo $NODE_ENV
production

I can echo $NODE_ENV all day and it will continue to show me “production”, but when I do process.env.NODE_ENV in my Node application it always displays “undefined”.

$ node app.js
Value: undefined

Here is the odd part though, if I display another environment variable that I know already exists, say process.env.PATH, then it works.

$ node app.js
Value: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Another quirk is that the command printenv list doesn’t appear to contain my custom variable NODE_ENV despite the fact that echo $NODE_ENV shows me the correct value. printenv NODE_ENV shows nothing as well, but printenv PATH shows the proper value just as it did when I accessed PATH in my node application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:58:29+00:00Added an answer on June 4, 2026 at 2:58 pm

    You need to export shell variables in order to make them available to processes you execute in your shell.

    Compare the output of this command:

    FOO=bar; bash -c 'echo $FOO'
    

    with the output of this:

    export FOO=bar; bash -c 'echo $FOO'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Ubuntu, I am trying to download a file (from a script) using wget.
On Ubuntu Linux, with Bash, I have /etc/profile set with read-only variables on login.
Running Ubuntu 11.10 + python2.7...built numpy from source and installed it, but when I
In Ubuntu, I'd like to switch my JAVA_HOME environment variable back and forth between
OpSys: Ubuntu 10.04 LTS Passenger: passenger-3.0.13 Nginx: nginx-1.2.1 Trying to install from source nginx
In ubuntu bash script how to remove space from one variable string will be
ubuntu 9.04, fedora 11, redhat... what are the differences from a web server/development standpoint?
Using Ubuntu, when I run bundle install to set up my Rails environment, it
In Ubuntu it's quite simple; I can run the application using: $ NODE_ENV=production node
The Ubuntu equivalent would be libc6-dev , but I can't seem to find it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.