process.env.NODE_ENV is undefined

后端 未结 13 1808
南旧
南旧 2020-11-28 18:26

I\'m trying to follow a tutorial on NodeJs. I don\'t think I missed anything but whenever I call the process.env.NODE_ENV the only value I get back is undefine

13条回答
  •  隐瞒了意图╮
    2020-11-28 19:04

    In macOS for those who are using the express version 4.x.x and using the DOTENV plugin, need to use like this:

    1. After installing the plugin import like the following in the file where you init the application: require('dotenv').config({path: path.resolve(__dirname+'/.env')});

    2. In the root directory create a file '.env' and add the varaiable like:

      NODE_ENV=development or NODE_ENV = development

提交回复
热议问题