code . is not recognized as an internal or external command

怎甘沉沦 提交于 2019-12-03 11:50:47

问题


I want to open directory using cmd in visual studio code but its give me error in cmd. So, What setting is require for that?

I have performed below command

D:\RND>code .

回答1:


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

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 setx path "%path%;C:\Program Files (x86)\Microsoft VS Code\bin"
  3. Restart terminal



回答2:


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




回答3:


Make sure you know where is the installation of VS Code, it can be in Program Files (x86) if you installed the 32bits version or Program Files if you installed the 64bits version VS Code location Once you know that Run (Win+r) cmd and type: setx path "%path%;C:\Program Files (x86)\Microsoft VS Code"

or

setx path "%path%;C:\Program Files\Microsoft VS Code"

after that, you can type code . to open VS Code with the project of the current folder.




回答4:


O/S windows

Setting the environment variable path to C:\Users\chawki\AppData\Local\Programs\Microsoft VS Code\bin solve the issue.




回答5:


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:

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".

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.



来源:https://stackoverflow.com/questions/46638944/code-is-not-recognized-as-an-internal-or-external-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!