37

Consider:

Enter image description here

I just started with Angular. I installed angular/cli and added a project. Now I want to use Visual Studio Code.

I open the Command Palette (Ctrl + Shift + P) and type 'shell command' to find the shell command: Install 'code' command in PATH command.

But I get this message

"No commands matching"

Why does it not exist?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mahrooy
  • 396
  • 1
  • 3
  • 7

12 Answers12

43

With Windows it is installed by default so you don't need to add path. Just run " code . " in cmd and it will work fine

jeff porter
  • 6,560
  • 13
  • 65
  • 123
  • 3
    thats not true, not by default on windows – Devmyselz Sep 16 '22 at 10:56
  • @Devmyselz I just made a fresh installation of latest vscode in Windows 11, and it's install by default. Just remember to close and open your terminal in order to have the command available. – Ema Suriano Jun 04 '23 at 08:46
18

If in Visual Studio Code doesn't appear that option and the installation didn't add to the path directly, you can add the Visual Studio Code bin folder manually to the path and it starts to work.

Go to the Enviroment Variables and edit the Path user variable. Inside of it, add a new variable with the current bin path of your Visual Studio Code installation. Mine, for example, is "C:\Users\Inazio\AppData\Local\Programs\Microsoft VS Code\bin"

Visual Studio Code code command enviroment variable

After that, you can start to use the code command in your OS

Inazense
  • 1,517
  • 3
  • 18
  • 28
  • 1
    This worked for me. For new users on windows - like me - click on the windows icon, search for 'environment variables' this gives the option to edit the system environment variables... edit it there. The simplest solution to this irritating problem – OctaviaLo Jul 24 '19 at 09:38
  • 1
    %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\bin – Devmyselz Sep 16 '22 at 10:58
3

I had this same problem. Long story short, I uninstalled VS Code, re-downloaded the installer package and ran that. Sure enough, one of the install screens has a checkbox option to add to the PATH variable and this option is unchecked by default.

Checked the box, finished the install, works fine.

Of course it's perfectly valid to modify the PATH variable after install, but I think it's important to clarify that (at least version 1.23.0) does not update PATH by default. Most of the threads I looked at says it does.

scottmwyant
  • 305
  • 1
  • 2
  • 9
  • Here is how you can do it easily from VS Code: https://stackoverflow.com/questions/30065227/run-open-vscode-from-mac-terminal – Bertil Baron Mar 30 '20 at 08:34
2

This works for me

For Windows users

Open Environment Variables

System > Advance system settings > Advanced tab > environment variables on system variables click on Path and click Edit and add new Path named

"C:\Users\Your-Username\AppData\Local\Programs\Microsoft VS Code\bin"

For window users follow steps below and add new Path, after doing so restart your terminal you will get code command on your terminal

enter image description here

Hanzla Habib
  • 3,457
  • 25
  • 25
1

I fixed this just adding "C:\Users\myUser\AppData\Local\Programs\Microsoft VS Code\Code.exe" (where myUser is your windows user) without "" to system path.

same effect than " Shell Command: Install ‘code’ command in PATH ".

Robert
  • 5,278
  • 43
  • 65
  • 115
Ivan Tejo
  • 11
  • 1
  • 2
  • This worked perfectly for me. Now I can open `code .` from `cmd` and `wsl2` using `Ubuntu-20.04` with `Hyper`. – robe007 Jul 01 '20 at 21:11
1

If you already have Visual Code into Windows path and in a terminal you put "code ." and Visual Code starts, what happens is that the command "code" is not linked to the path in wsl2. All you have to do is run the following command changing your user:

sudo ln -s /mnt/c/Users/CHANGE_USER/AppData/Local/Programs/Microsoft
VS\ Code/bin/code /usr/bin/code

This works on Ubuntu and Debian.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jorge Novo
  • 377
  • 3
  • 4
0

it is already installed on Windows. You just have to make cmd path where the project created (e.g C:\WINDOWS\system32> cd C:\WINDOWS\system32\hello-world), then run the the comamnd "code ." like this (C:\Windows\System32\hello-world>code .)

example

I got this from VS Code documentation

0

the path has been set automatically when installing VS.But i noticed a difference between "code." and "code ." Can you see the difference? The second has space in between the code and the dot. Try that.

0

I was having the same exact problem and when i checked my PATH variable it said that the path was something\something\Microsoft VS Code . then i remembered my folder's name was Visual Studio Code.After I renamed it back everything works.

0

Go to Extensions and install Shell. On newer versions you can just type in Code . in CMD and it will pop-up.

Tig7r
  • 525
  • 1
  • 4
  • 21
-3

Just open your command prompt and type:

cd hello-world

hello-world is the project name don't forget to change it then click (enter) and type

code .

enter image description here

phwt
  • 1,356
  • 1
  • 22
  • 42
-4

Visual Code already have internal terminal window

Use the Ctrl+` keyboard shortcut with the backtick character.

Its supports all Ubuntu terminal commands

Nawrez
  • 3,314
  • 8
  • 28
  • 42
Palani samy
  • 115
  • 3