require(“child_process”).exec执行报错 路径中有空格会导致执行报错,因为路径中有空格,exec会认为这是两个命令,解决方法 path = '\"'+path+ '\"' // 加上转义引号 exec(`${path}`,{encoding:'GBK'},(error, stdout, stderr) => { console.log(error, stdout, stderr); if (error) { return; } else { } });