There are a lot of useful recommendations in other answers. I'm generally doing it like this:
const environment = process.env.NODE_ENV || 'development';
The good thing is that such approach is not specific to Express per se, but actually is an accepted practice in wider Node.js ecosystem.
Also, I've implemented a reusable module, which allows to automatically detect environment by analyzing both CLI arguments and NODE_ENV variable. This could be useful on your development machine, because you can easily change environment by passing a CLI argument to you Node.js program like this: $ node app.js --prod
.
Please see more details and use cases on the detect-environment
's page.