---
# System prepended metadata

title: NodeJS code documentation

---

# NodeJS code documentation



Child Process
---
The `child_process.spawn()` method spawns a new process using the given command, with command line arguments in args. If omitted, args defaults to an empty array

`child_process.spawn(command[, args][, options]);`

- `command` <string> The command to run.
- `args` <string[]> List of string arguments.
- `options` <Object>


Use `cwd` to specify the working directory from which the process is spawned. If not given, the default is to inherit the current working directory.

Use `env` to specify environment variables that will be visible to the new process, the default is process.env.

Example running `python temp.py`
```
const spawn = require('child_process').spawn; // call the function child_process.spawn()
const file = __dirname + 'temp.py' //define the file path
...
spawn('python', [file], {cwd: '/tmp'}); //spawn the python command to run the "file"
```
This basically grabs the module API, then the spawn method off of that and aliases it to a local variable for use later in the code
