How do you detect the environment in an express.js app?

后端 未结 6 998
谎友^
谎友^ 2020-12-23 01:48

How do you detect what environment an expressJS app is running in? (development, test, production?). There\'s nothing in process.env indicating an environment..

6条回答
  •  悲哀的现实
    2020-12-23 02:23

    You can either check the environment by checking the app.settings.env (this will work in Express), or you can do it in a more direct way by checking process.env.NODE_ENV (the environment is the one found in that variable or 'development' by default < this also works in other libraries such as Socket.IO etc).

提交回复
热议问题