Friday 20 July 2018

Why can't I access nodeJS CLI arguments when my program spawns a child process?

Simplified version of code here:var spawn = require("child_process").spawn; var x = process.argv[2] console.log(x); var process = spawn('python'); The code errors out with "TypeError: Cannot read property 'argv' of undefined". The first and final lines work fine together, and the code will read the argvs fine if the final line is commented out, they just fail to work together.

Submitted July 20, 2018 at 11:24PM by DeadeyeDuncan

No comments:

Post a Comment