You can use process.env.NODE_ENV
to check the value of the NODE_ENV
environment variable in Node.JS:
if(process.env.NODE_ENV == "development") { // TODO your code goes here }
or
if(process.env.NODE_ENV == "production") { // TODO your code goes here }
Note that by default NODE_ENV
is undefined
so remember to handle that case appropriately.