code . is not recognized as an internal or external command

For me it was due to not running cmd as an administrator. (Right click Command Prompt -> Run as Administrator)


if using Windows:

  1. Press the "Windows"-button
  2. Type "Visual Studio Code"
  3. Right click on "VS Code" (or "Visual Studio Code")
  4. Click on "Open file location"

You will then be directed to a folder, where either the VS Code program is or a VS Code shortcut is.

If it is the shortcut, then right click on it and again press "Open file location". Copy the path:

path picture

which in my situation will be: "C:\Program Files\Microsoft VS Code"

And then do as Chawki posted - paste it into your "Environmnet variables" under "Path".

screenshot of environment variable

This is just to show, that the two above might not be the solution for you (they weren't for me).

Should this still not work for some reason then try restarting the terminal and/or add "/bin" to the path you have added inside your environment variable.


It needs to be setup so that Code is found in your PATH. If you're on a mac system, do the following (for windows systems, read below):

  1. Launch VS Code
  2. Open up command palette (press F1) and type shell command to find Shell Command: Install 'code' command in PATH command.
  3. Restart terminal

VSCode screen capture

If you're on Windows, you can also set the PATH manually by adding:

C:\Program Files (x86)\Microsoft VS Code\bin

to your PATH environment variable.

  1. Open command prompt
  2. Type the command - setx path "%path%;C:\Program Files (x86)\Microsoft VS Code\bin"
  3. Restart terminal

Update: If you're on Windows 10 and VSCode 1.47.2 and above, the new PATH has to be set to:

C:\Users\{username}\AppData\Local\Programs\Microsoft VS Code\bin

If you have the insider's editions of vscode installed, the command will be code-insiders.