to extend the environment variables for a child process, the environment of the parent should be duplicated, and then extended, as follows
How to Optimize CPU-Intensive Work in Node.js

Another way of creating an extended copy of an Object, which I quite like, is using Object.assign.

Sharing as you might like this approach as well.

var child_process = require('child_process');
// Duplicate the parent's environment object
// and extend this with some new variables:
var envDup = Object.assign({}, process.env, {
'VAR NAME': 'var value'
// Run child process with these environment variables
child_process.exec('ls', { env: envDup }, function(err, stdout, stderr) {
if (err) {
throw err;
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.