basheps basheps - 1 year ago 344
Javascript Question

process.env.NODE_ENV is undefined

I'm trying to follow a tutorial on NodeJs. I don't think I missed anything but whenever I call the

the only value I get back is undefined. According to my research the default value should be 'development'. How is this value dynamically set and where is it set initially?

Answer Source

process.env is a reference to your environment, so you have to set the variable there.

To set an environment variable in Windows:

SET NODE_ENV=development

on OS X or Linux:

export NODE_ENV=development
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download