I am really new to NodeJS and playing around with some functions. I want to use some commands from cmd using Node. My attempt was this here:
const execSync = require('child_process').execSync;
code = execSync('node -v');
console.log(code);
But instead of getting a one-liner, I am getting a whole ChildProcess object like this:
ChildProcess {
_events: [Object: null prototype] {
close: [Function: exithandler],
error: [Function: errorhandler]
},
_eventsCount: 2,.....and so on
Can anyone guide me please? Why is that so and how can I do it?