Spawn Child Process
NodeJS
Hard
3 views
Problem Description
Run 'node -v' using child_process and print the version.
Output Format
Print version.
Constraints
Use execFile for safety.
Official Solution
const { execFile } = require('child_process');
execFile(process.execPath, ['-v'], (err, stdout) => {
if (err) return console.log('FAIL');
console.log(stdout.trim());
});
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!