nodejs execute file code example
Example 1: node execute shell commands
const { exec } = require("child_process");
exec("cat index.js", (error, data, getter) => {
if(error){
console.log("error",error.message);
return;
}
if(getter){
console.log("data",data);
return;
}
console.log("data",data);
});
Example 2: javascript running at node
const inNode = new Function('try{return this===global;}catch(err){return false;}')();