visual-studio-code - 指定 tasks.json shell 命令的路径
问题描述
在 tasks.json 中,如何指定 shell 命令的路径?我试过:
{
"label": "launch site local (ngserve)",
"type": "shell",
"group": "build",
"command": "C:/Users/me/npm start",
"problemMatcher": ["$tsc"]
}
退出并出现错误:
/usr/bin/bash: C:/Users/me/npm: No such file or directory 终端进程以退出代码终止:127
解决方案
我意识到命令字符串可以包含多个命令,所以我使用 && 链接它们并做了:
{
"label": "launch site local (ngserve)",
"type": "shell",
"group": "build",
"command": "cd C:/Users/me && npm start",
"problemMatcher": ["$tsc"]
}
请注意,此解决方案是特定于默认 shell 的(powershell 不能很好地处理这个问题)——我在 windows 上使用 Git Bash。
您可以通过将选项参数添加到上述任务来更改特定命令的默认 shell。选项参数如下所示:
更改 git bash shell 位置的路径
"options": {
"shell": {
"executable": "C:\\Windows\\System32\\cmd.exe",
"args": ["/d", "/c"]
}
推荐阅读
- f# - 为什么 F# seq 以小写字母开头?
- c++ - 列表初始化如何工作?是否有任何超载?
- amazon-cloudformation - EKS 集群无法添加服务帐户 EntityAlreadyExists:提供 url https://oidc.eks
- html - 内容部分位于侧边栏下方
- javascript - NextJS 在客户端和服务器端获取数据
- discord - 如何修复 discord.js 中的“CLIENT_MISSING_INTENTS”错误?
- swift - 如何在 swift 对象上获取 UnsafeRawPointer?
- arrays - 为什么没有 F# 不可变数组?
- javascript - 滚动条不会出现在 CSS 的下拉列表中
- python - cvxopt 线性规划中的 ValueError (Rank(A) < p 或 Rank([G; A]) < n)