我正在尝试在 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"
}
},
]
}