Rilcon42
Rilcon42

Reputation: 9763

Specify path for tasks.json shell command

In a tasks.json how can I specify the path for a shell command? I tried:

{
  "label": "launch site local (ngserve)",
  "type": "shell",
  "group": "build",
  "command": "C:/Users/me/npm start",
  "problemMatcher": ["$tsc"]
}

which exited with the error:

/usr/bin/bash: C:/Users/me/npm: No such file or directory The terminal process terminated with exit code: 127

Upvotes: 1

Views: 3191

Answers (1)

Rilcon42
Rilcon42

Reputation: 9763

I realized the command string could hold multiple commands so I chained them using && and did:

{
  "label": "launch site local (ngserve)",
  "type": "shell",
  "group": "build",
  "command": "cd C:/Users/me && npm start",
  "problemMatcher": ["$tsc"]
}

Note that this solution is default shell specific (powershell doesnt handle this well)- I am using Git Bash on windows.

You can change your default shell for a specific command by adding the options param to the task above. The options param looks like this:

Change the path to git bash shell location

  "options": {
    "shell": {
      "executable": "C:\\Windows\\System32\\cmd.exe",
      "args": ["/d", "/c"]
    }

Upvotes: 1

Related Questions