VSCode版本:1.37
操作系统版本:window 1895(在mac os中没有问题)
// extension.ts
export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "spawn-demo" is now active!');
let disposable = vscode.commands.registerCommand(
"extension.spawnNotepad", // this work, notepad can launch
() => {
spawn("notepad");
}
);
let disposable2 = vscode.commands.registerCommand(
"extension.spawnTypora",
() => {
// The code you place here will be executed every time your command is executed
console.log('working')
const child = spawn("Typora");
child.on("error", e => {
console.log("error", e);
});
child.on("close", (c, s) => {
// c == 0, s ==null
console.log("close", c, s); // close immediately
});
child.stderr.once("data", d => {
console.log("stderr", `${d}`);
});
child.stdout.once("data", d => {
console.log("stdout", `${d}`);
});
}
);
context.subscriptions.push(disposable);
context.subscriptions.push(disposable2);
}
require('child_process')。spawn('Typora')在节点表示中很好地工作
在禁用所有扩展后是否会发生此问题?:是