Answers for "shell commands in the browser js'"

1

running shell commands javascript

const execSync = require('child_process').execSync;
// import { execSync } from 'child_process';  // replace ^ if using ES modules

const output = execSync('ls', { encoding: 'utf-8' });  // the default is 'buffer'
console.log('Output was:\n', output);
Posted by: Guest on December-26-2021
0

shell commands in the browser js'

const { exec } = require('child_process');
  exec('ls', (error, stdout, stderr) => {
    if (error) {
        console.error(`exec error: ${error}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
    console.error(`stderr: ${stderr}`);
  });
Posted by: Guest on March-16-2022

Code answers related to "shell commands in the browser js'"

Code answers related to "Javascript"

Browse Popular Code Answers by Language