如何在node.js中设置环境变量?

时间:2020-12-14 22:50:03

How can I set an environmental variable in node.js?

如何在node.js中设置环境变量?

I would prefer not to rely on anything platform specific, such as running export or cmd.exe's set.

我不希望依赖于任何特定平台,比如运行export或cmd。exe的集合。

1 个解决方案

#1


119  

You can set your environment variables in process.env:

你可以在进程中设置你的环境变量。

process.env['VARIABLE'] = 'value';

Node should take care of the platform specifics.

节点应该注意平台的细节。

#1


119  

You can set your environment variables in process.env:

你可以在进程中设置你的环境变量。

process.env['VARIABLE'] = 'value';

Node should take care of the platform specifics.

节点应该注意平台的细节。