默认输出是Buffer对象
const { execSync } = require('child_process')
let out = execSync("echo 'hi'")
console.log(out);
// <Buffer 68 69 0a>
需要转为字符串文章来源:https://uudwc.com/A/EybL0
const { execSync } = require('child_process')
let out = execSync("echo 'hi'")
console.log(out.toString());
// hi
参考文章文章来源地址https://uudwc.com/A/EybL0
- https://www.runoob.com/nodejs/nodejs-process.html
- https://blog.csdn.net/weixin_43972437/article/details/130643741