node执行cmd命令乱码问题 Gary Wang 2023-03-24 前端 node 先将encoding设置为buffer,然后使用iconv-lite模块解码 需要管理员身份运行cmd.exe 123456789//先将encoding设置为buffer,然后使用iconv-lite模块解码const iconv = require('iconv-lite');const childProcess = require('child_process');childProcess.exec(`ping www.baidu.com`, { encoding: 'buffer' }, (error, stdout) => { console.log('stdout1', iconv.decode(stdout, 'cp936'));});