VS Code 默认会使用系统中配置的 shell(如 PowerShell、cmd、bash 等)。如果该 shell 启动时执行了某些命令导致立即退出,就会出现"一闪而退"。
解决方法:
- 打开 VS Code 设置(
Ctrl + ,),搜索terminal.integrated.defaultProfile。 - 检查你当前平台(Windows/macOS/Linux)对应的默认终端配置是否正确。
- 例如在 Windows 上,可以尝试切换为
Command Prompt或PowerShell:
"terminal.integrated.defaultProfile.windows": "Command Prompt"
亲测有效。