Categories
JavaScript Answers

How to set an environmental variable in Node.js?

Spread the love

Sometimes, we want to set an environmental variable in Node.js.

In this article, we’ll look at how to set an environmental variable in Node.js.

How to set an environmental variable in Node.js?

To set an environmental variable in Node.js, we can set it as a property of the process.env property.

For instance, we write

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

or

process.env.VARIABLE = 'value';

to set the VARIABLE environment variable to 'value'.

Conclusion

To set an environmental variable in Node.js, we can set it as a property of the process.env property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *