Answers for "shell for node.js"

1

running shell commands nodejs

const exec = require('child_process').exec;
const child = exec('cat *.js bad_file | wc -l',
    (error, stdout, stderr) => {
        console.log(`stdout: ${stdout}`);
        console.log(`stderr: ${stderr}`);
        if (error !== null) {
            console.log(`exec error: ${error}`);
        }
});
Posted by: Guest on December-27-2021
0

running shell commands nodejs

const system = require('system-commands')

system('ls').then(output => {
    console.log(output)
}).catch(error => {
    console.error(error)
})
Posted by: Guest on December-27-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language