bashvisual-studio-code

cant use sudo, apt ,npm, etc in my vscode terminal even though I have Ubuntu bash installed on Windows 10


VSCode Version: 1.22 OS Version: Windows 10

explanation of issue:

I Entered something Basic Like sudo apt update or npm update inside my vscode integrated terminal and I get This Error Message: bash: sudo: command not found bash: npm: command not found

I Have the Ubuntu Bash installed on my windows 10 OS but inside my vscode terminal these commands dont work (even though they work inside the default terminal on my desktop).

How Can I fix this problem so I can strictly use the terminal in vscode and not a separate terminal, in order to save space on my screens?


Solution

  • This is explained in the documentation for VS Code (which has various options), but to avoid this being a link-only answer:

    Set the "terminal.integrated.shell.windows" VS Code configuration variable to "C:\\Windows\\System32\\bash.exe" and you should be good to go.

    For convenience, there's also a Select Default Shell command in the command palette which sets this for you.