exec() spawns a shell and executes the command within that shell. Any generated output gets buffered.
Unlike spawn(), the command is entered as a single string, without any array containing parameters.
// Require necessary modules
const childProcess = require('child_process');
const os = require('os');
// Show OS/kernel version
console.log(`Kernel version: ${os.release()}`);
// Show current working directory (CWD)
console.log(`CWD: ${process.cwd()}`);
Now creating instance of child_process.spawn()
Goal is to show the contents of the root directory using native 'ls'-command.