Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find out the current NODE_ENV the express app is running under?

I was just wondering if i can find out what is the current value of NODE_ENV (i.e. either development or production) in a express code (so i can't use app.configure('production' function(){})).

like image 561
FurtiveFelon Avatar asked Feb 25 '12 04:02

FurtiveFelon


People also ask

What is the default NODE_ENV?

By default, the environment variable is unset and defaults to development.

How do I find the process environment?

Solved: start by typing node and pressing enter, then type process. env and press enter.

What is the NODE_ENV?

NODE_ENV is an environment variable that stands for node environment in express server. The NODE_ENV environment variable specifies the environment in which an application is running (usually, development or production).


2 Answers

Try process.env.NODE_ENV

It should do the trick.

like image 113
j_mcnally Avatar answered Oct 01 '22 08:10

j_mcnally


Within your express script, app.settings.env should house that value.

like image 25
Dominic Barnes Avatar answered Oct 01 '22 07:10

Dominic Barnes