abrkn abrkn - 6 months ago 12
Node.js Question

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

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

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

Answer

You can set your environment variables in process.env:

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

Node should take care of the platform specifics.