Is there a way to display NODE_ENV from the command line?

Please, answers here all refer to a something called process.env.NODE_ENV, but echo $process.env.NODE_ENV from the command line did not work. Any ideas?


Use echo $NODE_ENV. The command line is a shell, probably bash and that's the bash syntax to print the value of an environment variable.


If you have defined NODE_ENV variable then you should be able to see this by typing node in the command prompt which will open the node cell and then type process.env.NODE_ENV.

To check the existing env variables .. type this .. process.env


You call list all variables for Macs available for your project directory with...

printenv

I use this often to look for the NODE_ENV and other variables.


go to node REPL, and then give process.env.NODE_ENV and the variable process is scoped inside nodejs process, not in your shell process.

sk3037@saravana:~/src$ node
> process.env.