Welcome to the Linux Foundation Forum!

LFW211 lab 15.1 AssertionError [ERR_ASSERTION]: child process should have only one env var

this problem was touched on in the past, title: Lab 15.1 problem. Path to child.js, but was originally related to a different problem.

windows 10 with cmd.exe

when providing the spawn options object with the env property set to a new key/value pair, the result is a minimal set of environment variables (11) with the addition of the new key/value set in the options object. the minimal set contains:


with the following code in index.js

'use strict'

function exercise (myEnvVar) {
  return require('child_process').spawnSync(process.argv[0], ['child.js'],{
    env: {MY_ENV_VAR: myEnvVar}

module.exports = exercise

an assertion error is thrown which notes the actual value received was 12 but the expected value was 1. after perusing the internet, it appears the functionality may have changed at some point in the past with how windows or node handles new processes. i found a few sources (including the lesson) that stated the above should overwrite all environment variables in the child process. whether it's node or windows, there doesn't seem to be an obvious way to create a child process with an empty or custom set of environment variables without the addition of the minimal set described above.

the values of the environment variables in the minimal set can be overwritten but there doesn't seem to be a way to remove any one or all of them.

it doesn't seem to be the point of the lab to learn how to remove environment variables from a child process so it may be prudent to remove the assertion from child.js which tests for the number of keys in the child process.env. if this test has some further use in linux environments, maybe an if block could be added to child.js to exclude the test on windows platforms:

if (process.platform !== 'win32') {
    'child process should have only one env var'


  • cscharr
    cscharr Posts: 4


    Just stumbled upon this :neutral:

  • xdxmxc
    xdxmxc Posts: 9

    working on a fix for this - still need a way to establish a blank env was passed on windows but you are right, hard coding the minimal set doesn't make sense given the churn on Windows. I have a windows laptop coming in a few days and will implement a fix as soon as I have it set up

  • I also encountered this issue.


Upcoming Training