【发布时间】:2022-05-18 03:07:32
【问题描述】:
我正在尝试在 VSCode 中运行一个窗口加载任务,其中终端打开,nvm use && yarn dev 默认运行。但是,运行这个 shell 任务似乎没有加载我的 zsh 配置文件。
我运行任务得到的输出是:
The terminal process "zsh '-c', 'nvm use && yarn dev'" terminated with exit code: 127.
Terminal will be reused by tasks, press any key to close it.
但是,如果我随后手动启动一个新终端并运行相同的命令(即:按加号,打开一个新的集成终端),它将按预期工作。
怀疑 VSCode 出于某种原因没有加载我的个人资料,我尝试将以下内容添加到我的任务中,导致错误 /bin/zsh: can't open input file: nvm use && yarn dev The terminal process "zsh '-l', 'nvm use && yarn dev'" terminated with exit code: 127.。
// in dev task
"options": {
"shell": {
"executable": "zsh",
"args": ["-l"]
}
},
.vscode/tasks.json
{
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true
},
"tasks": [
{
"label": "Create terminals",
"dependsOn": [
"Dev",
],
// Mark as the default build task so cmd/ctrl+shift+b will create them
"group": {
"kind": "build",
"isDefault": true
},
// Try start the task on folder open
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "Dev",
"type": "shell",
"command":
["nvm use && yarn dev"],
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "dev-group"
}
},
]
}
【问题讨论】:
-
我也有同样的问题,没有一个答案能解决这个问题。为此github.com/microsoft/vscode/issues/143061打开了一个错误
标签: visual-studio-code zsh nvm