21

I added a directory to my PATH but the terminal in my VS Code doesn't recognize a command(exe) that I'm trying to run from that directory. The terminal uses cmd not power shell. What am I missing?

neomib
  • 3,503
  • 4
  • 17
  • 27

6 Answers6

26

Restarted my computer and it worked :) Apparently VS Code didn't recognize the changes.

neomib
  • 3,503
  • 4
  • 17
  • 27
  • 2
    Thanks,, but i just restarted the VS code itself – Vattic Dec 03 '22 at 09:28
  • 1
    In my case restarting VSCode didn't help, all built-in terminals didn't see the new PATH value. Singing out and in my Windows account helped. – AKd Mar 19 '23 at 12:23
18

For me, a simple restart of VSC did the trick.

avi.elkharrat
  • 6,100
  • 6
  • 41
  • 47
  • Helpful. Thanks – raiyan22 Jun 11 '23 at 18:36
  • Note that 'Restart to Update' does not pick up the new PATH when it starts again. Click X to close the app, check that the VS Code process is not present in Task Manager then open VS Code again, either from shortcut or by entering `code` in a cmd window. Then it picked up the updated PATH. – MikeA Aug 23 '23 at 16:37
7

If your VS Code terminal shows "Session Restored" after restarting, then it may still be using the variables from before you rebooted! If this happens, close and re-open the vscode window, or kill and restart the terminal tab.

nupanick
  • 754
  • 8
  • 13
4

Clicking the bin/trash icon on the terminal to properly kill it and then CTRL + ' to open a new terminal works best. No need to close the app or shut down your PC.

enter image description here

Fred Johnson
  • 2,539
  • 3
  • 26
  • 52
  • A screenshot of this "bin icon" might help (not everyone calls the trash button a "bin"). Also, can do this through the command palette: "**Terminal: Kill the Active Terminal Instance**" and then "**Terminal: Create New Terminal**". – Gino Mempin Jan 26 '22 at 07:16
0

I had some files remaining in the folder 'c:\Program Files\nodejs', deleted the folder and it all worked.

Worthy7
  • 1,455
  • 15
  • 28
0

If nothing works and you don't want to restart your computer.

For windows;

  1. Open a command prompt (outside vscode) and type echo %PATH%
  2. Copy the path
  3. Open your terminal in vscode and type PATH=<your-path> (replace <your-path> with the output)

Note: This is a temporary solution and goes away if you close the terminal and open a new one.

KlinZ
  • 28
  • 6