VSCode tasks error: /bin/bash: npm: command not found
Since this is the first result on Google, I want to share my solution despite this being a year old. The problem is that VS Code isn't initializing the NPM command, and many others when using VS Code Tasks. The solution to this is to force VS Code to do so.
This is a very simple thing to do. Simply open up settings.json and add this:
{
"terminal.integrated.shellArgs.linux": [
"-i"
]
}
I know that this thread is a year-old, but it's the first result I found on Google when going on my search, and while AskYous's solution worked for him, it didn't for me.
see comments for changes due to new versions of VSC (1.60.1+?)
Update to @VirxEC's answer for newer versions of VSCode (1.60+ ?) the correct setting is (change the actual shell path/name as desired):
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash",
"args": ["-i"]
}
},
For versions where there is warning for VirxEC solution, can use
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "zsh",
"args": [
"-i"
]
}
},
"terminal.integrated.defaultProfile.osx": "zsh",
from https://code.visualstudio.com/docs/editor/integrated-terminal#_terminal-profiles