19

this is the line i get when i did shell command in VS code

I get this error:

code . is not recognised as an external or internal command, operable program or batch file

moreover shell commands are not coming in my compiler VS code neither do setx path "%path%;C:\Program Files\Microsoft VS Code" is working in command prompt .

4
  • Did you just recently install VS Code? If so, did you restart the Command Prompt after installation?
    – vcsjones
    May 4, 2018 at 20:19
  • Did you have a terminal open?
    – Natsfan
    May 5, 2018 at 0:51
  • @vcsjones yes i have recently installed VS code and i have restarted Command prompt after installation
    – Nikhil S
    May 5, 2018 at 10:52
  • Possible duplicate of code . is not recognized as an internal or external command
    – d.moncada
    May 6, 2018 at 2:31

10 Answers 10

47

It looks as if you do not have the code program installed. You can open the Command Palette,

  • Mac: ShiftCmdP
  • Windows/Linux: ShiftCtrlP

And search "install command", which should return this as one of the options:

  • Shell Command: Install 'code' command in PATH

Run that, and it should install the code command, after which you should be able to use it.

1
21

For Mac OS, You can paste this into your terminal, or in your .bashrc file (or whatever shell config file you are using) :

export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
3
  • in cmd its its showing up -'export' is not recognized as an internal or external command, operable program or batch file.
    – Nikhil S
    Sep 25, 2018 at 16:49
  • Worked for me on macOS Mar 16, 2019 at 21:59
  • 1
    I'm using the Insiders version. This worked for me: export PATH="$PATH:/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin". Thank you!
    – fanta
    Jul 11, 2019 at 3:15
8

I found it. In the "search" type environment variables then click on the "edit system environment variables".

Inside Environment variables->Path put C:\Users\{your_username}\AppData\Local\Programs\Microsoft VS Code\bin.

Go to the project folder and open the cmd with it typing in the location bar and then type code .

That will do.

1
  • Make sure that the Environment variables for this path is in the first place. If not move to the top. This worked for me only after moving this path to first place in the order.
    – psuneel127
    Jul 13, 2020 at 15:52
3

make sure you run the command in C folder

Then click window key + R and type rundll32.exe sysdm.cpl,EditEnvironmentVariables then enter . It will open Environment Variables edit Path variable . Check whether you have C:\Users\{pc name}\AppData\Local\Programs\Microsoft VS Code\bin if not add it and run code -v in C folder cmd

This worked for me !

2

in windows problem is with insiders version of VSC. You can use 'code-insiders .' command or make a copy of 'code-insiders.cmd' file as 'code.cmd' inside folder with code-insider (use 'path' command to see where your VSC is installed)

1
  • This works with WSL in Linux shell. Very helpful thx! Path to 'code-insiders' is maybe \home\<user>\.vscode-server-insiders\bin\. . .\bin ('.' directories/files are hidden by default so you can use ls -ld .* to view them. Oct 28, 2021 at 15:51
2

For Windows OS

For Windows, you'll need to re-install code. You can download the latest version and just install it overtop of your existing install.

During setup, make sure to check the box to Add to PATH

Setup - Add to Path

See Also: The VSCode docs on installing the CLI

1

I recently had to modify the path from /bin to /_

this is what I used after clicking the edit path variables section and it worked.

C:\Users\{user_name}\AppData\Local\Programs\Microsoft VS Code\_

make sure the path variable refers to the location of the .exe

0

After installation, you need to restart your computer to make the PATH changes effective. Post restart, the command worked for me.

0

about linux, if u can't see the >shell option with ctrl+shif+p, You could install via

sudo snap install --classic code

and try again

code .

0

Just adding here since the above answers did not work for me. On windows ten when updating the path do not add the /bin. So the added pat should be C:\Users\{user_name}\AppData\Local\Programs\Microsoft VS Code\

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.