Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove a value in process.env?

I want to remove a value from process.env:

process.env.VALUE_I_WANT_REMOVED = undefined;

But when I do this, process.env.VALUE_I_WANT_REMOVED is set to the string "undefined", not to the value undefined.

How do I actually remove the value from process.env?

like image 344
Kevin Avatar asked Feb 10 '17 23:02

Kevin


1 Answers

Try this:

delete process.env.VALUE_I_WANT_DELETED;

According to the Node.js documentation:

Assigning a property on process.env will implicitly convert the value to a string.

Example:

process.env.test = null;
console.log(process.env.test);
// => 'null'
process.env.test = undefined;
console.log(process.env.test);
// => 'undefined'

Use delete to delete a property from process.env.

like image 101
Kevin Avatar answered Oct 14 '22 11:10

Kevin