Q:

How to start node app with development flag?

At top of my app.js file I put 
NODE_ENV='development';

but I get error that NODE_ENV is not defined. But in the nodejs documentation is says NODE_ENV is global. How can I start my app with development settings? Thank you.

A:

It is better to start your app in dev mode like this:
NODE_ENV=development node app.js

But if you really wanted to set it your app file just set it like this:
process.env.NODE_ENV= "development"

A:

NODE_ENV is an environment variable.
You set it in your shell when you invoke Node.js.
However, development is the default; you only need to do anything if you want prod.

A:

If you want to set an environment variable in your js file you should do it this way:
process.env.NODE_ENV = 'development';

Alternatively you can set the variable in your shell and run your application:
$ NODE_ENV="development" node ./app.js

or export the variable and run your application:
$ export NODE_ENV="development"
$ node ./app.js

On Windows:
$ set NODE_ENV="development"
$ node app.js

