node.js环境变量
The process
core module of Node provides the env
property which hosts all the environment variables that were set at the moment the process was started.
Node的process
核心模块提供env
属性,该属性承载在启动进程时设置的所有环境变量。
Here is an example that accesses the NODE_ENV environment variable, which is set to development
by default.
这是访问NODE_ENV环境变量的示例,该环境变量默认情况下设置为development
。
Note:
process
does not require a “require”, it’s automatically available.注意:
process
不需要“要求”,它是自动可用的。
process.env.NODE_ENV // "development"
Setting it to “production” before the script runs will tell Node that this is a production environment.
在脚本运行之前将其设置为“生产”将告诉Node这是一