process.env.NODE_ENV is undefined

后端 未结 13 1833
南旧
南旧 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 18:57

    For me, the issue was that I was using the pkg library to turn my app into an executable binary. In that case, the accepted solutions didn't work. However, using the following code solved my problem:

    const NODE_ENV = (process).pkg ? 'production' : process.env.NODE_ENV;
    

    I found this solution here on GitHub.

提交回复
热议问题