Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

code . is not recognized as an internal or external command

I want to open a directory using cmd in visual studio code but its giving me an error in cmd. So, what setting is required for that?

I have performed below command

D:\RND>code . 
like image 579
baj9032 Avatar asked Oct 09 '17 04:10

baj9032


People also ask

What is not recognized as an internal or external command in Visual Studio?

You can edit your path directly to add it: From the Start menu, type "variables" and choose the option to "Edit environment variables for your account". Locate the PATH entry and edit it. Add the directory where the code command exists, e.g. C:\Program Files\Microsoft VS Code\bin .

How do I fix Python not recognized?

Specify the full location to python.exe One way to fix the error would be to launch Python from the Command Prompt by passing in the full path to the executable file each time you wanted to run Python. In other words, instead of typing Python you would type something like C:\Users\me\path\to\python.exe .

How do I fix Java is not recognized as an internal or external command?

Here are the three easiest ways to fix Java's “not recognized as an internal or external command” error: Install or reinstall Java and the JDK on your computer. Add Java's bin directory to the computer's PATH. Restart the command prompt, terminal window or PowerShell.


2 Answers

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 
like image 62
d.moncada Avatar answered Oct 12 '22 23:10

d.moncada


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

like image 34
user3428422 Avatar answered Oct 13 '22 01:10

user3428422