Search code examples
node.jschild-processspawn

nodejs child_process pass cmd args down to script


I use child_process.spawn to create a new process: child_process.spawn('node', ['app.js', 'x']);

is there a way for me to get the cmd args(['app.js', 'x']) in app.js?


Solution

  • You should be able to access this in the usual way (the global process API) by accessing process.argv or process.execArgv within app.js