node equivalent of bash exec

const { exec } = require('child_process');

const command = 'ls -l';

exec(command, (error, stdout, stderr) => {
  if (error) {
    console.error(`Error: ${error.message}`);
    return;
  }

  if (stderr) {
    console.error(`Stderr: ${stderr}`);
    return;
  }

  console.log(`Output: ${stdout}`);
});