process.env.NODE_ENV未定义 [英] process.env.NODE_ENV is undefined

查看:2108
本文介绍了process.env.NODE_ENV未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试关注NodeJs的教程。我不认为我错过任何东西,但每当我调用 process.env.NODE_ENV 时,我得到的唯一值是未定义的。根据我的研究,默认值应该是开发。如何动态设置此值以及最初设置的位置?

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 undefined. According to my research the default value should be 'development'. How is this value dynamically set and where is it set initially?

推荐答案

process.env是对您的环境的引用,因此您必须在那里设置变量。

process.env is a reference to your environment, so you have to set the variable there.

设置 Windows中的环境变量

SET NODE_ENV=development

Linux

export NODE_ENV=development

这篇关于process.env.NODE_ENV未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆