我想在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"
}
},
]
}