Home > front end >  Visual Studio Code terminal commands not recognised in LInux
Visual Studio Code terminal commands not recognised in LInux

Time:10-18

I'm using the following version of VS Code on Linux Mint 20.3 Una XFCE Desktop -

Version: 1.71.2
Commit: 74b1f979648cc44d385a2286793c226e611f59e7
Date: 2022-09-14T21:12:14.256Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.4.0-126-generic
Sandboxed: No

When I launch the terminal through the menu Terminal>New Terminal it cannot recognise any commands for example -

sh: npm: command not found
sh-5.1$ 

*npm is installed on my system and is available through the terminal outside of vscode.

By the way, I get the same result when I try to execute any npm command through the Run menu.

What I've tried -

  • using different types of terminal eg/bash, sh, same result
  • Modifying the settings to use xfce4-terminal, it doesn't work and complains that it can't find the command xfce4-terminal

Also strangely when I navigate to /bin /usr/bin from the integrated vscode terminal the files look different from what I have on my system. For example npm and many others are missing.

Any suggestions would be most welcome!

CodePudding user response:

I've found the solution! It appears that the integrated terminal overrides the PATH variable present in .bashrc. To ensure PATH is set correctly, click on the settings button circled in yellow shown on the image. And simply add the PATH entry as shown. Of course you will need to replace the value of PATH to whatever you use on your system use the output of echo $PATH. Once this is done, reset your integrated terminal and you will have access to all the commands provided on your path!

settings.json

To run/debug the app (for Firefox, presumably the steps are similar for other browsers) from the Run menu -

  1. Install the required debugging plugin.
  2. Get the path to your browser eg/ whereis firefox.
  3. Add those paths to settings.json as shown.
  4. Add the configuration shown to launch.json as shown, or do it via the Add configuration button. To get to launch.json, try to run the App via the Run menu, and you will be signposted there by vscode.

running/debugging app from run menu

To view your config changes at anytime type @modified into the settings search bar. view modified settings

  • Related