node 执行 bat 命令:乱码、路径问题

乱码

index.js

const shell = require('shelljs');

shell.exec('aaa', function (code, stdout, stderr) {
});

执行 node index 出现乱码

先执行chcp 65001即可

路径

在当前目录执行不能加./(powershell下执行需要加),下面这个会报错

shell.exec('./test', function (code, stdout, stderr) {
});

这个报错似乎很友好,但和乱码同时出现就很懵了。纪念我的半个下午