1const { exec } = require("child_process");
2
3exec("ls -la", (error, stdout, stderr) => {
4 if (error) {
5 console.log(`error: ${error.message}`);
6 return;
7 }
8 if (stderr) {
9 console.log(`stderr: ${stderr}`);
10 return;
11 }
12 console.log(`stdout: ${stdout}`);
13});
14
1// With node.js installed in windows commandline
2C:\Users\Name> node
3> console.log("Hello World");
4Hello World
5undefined
6>
1$ node // now we can execute code in console
2> 2 + 4 //our input
36 //output
4> .exit // or ctrl + c