0

When I try to open with "code ." command from the windows terminal, it is throwing an error.

code : The term 'code' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ code .
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (code:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

It was opening fine before. No idea what happened. I tried reinstalling and the issue still remains

Suryaraj PS
  • 3
  • 1
  • 5
  • this is not a django question it should be tagged with ```cmd``` or ```powershell``` that being said, I figure that ```code``` was an alias for ```vscode```. You may want to look at [this](https://stackoverflow.com/questions/20530996/aliases-in-windows-command-prompt) – Nnaobi Apr 06 '22 at 06:18
  • this is not a django question it should be tagged with ```cmd``` or ```powershell``` that being said, I your vscode added to ```PATH```? Is the link to the ```PATH``` correct? – Nnaobi Apr 06 '22 at 06:28
  • During the installation there is an option to add vs code to your PATH. either uninstall and install code with this option, or you can add the install location to your PATH as noted from @Steven-MSFT – GeralexGR Apr 06 '22 at 14:46

2 Answers2

1

What's the result of where code in the CMD? it should be C:\Program Files\Microsoft VS Code\bin\code, C:\Program Files\Microsoft VS Code\bin\code.cmd if you install the VSCode in the default location.

Please add the parent folder path of code to the system environment of Path.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • the path in my case was: `C:\Users\{USER}\AppData\Local\Programs\Microsoft VS Code\bin` after changing the USER to the actual username. – Bilal Sep 29 '22 at 15:43
0

You have to add path to eviroment variable:

  1. Press the Windows key+X to access the Power User Task Menu.

  2. In the Power User Task Menu, select the System option.

  3. In the System window, scroll to the bottom and click the About option.

  4. In the System > About window, click the Advanced system settings link at the bottom of the Device specifications section.

  5. In the System Properties window, click the Advanced tab, then click the Environment Variables button near the bottom of that tab.

  6. In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button.

  7. In de popup windows click the New button.

  8. Enter your path for Visual Studio Code, something like this: "C:\Users{user}\AppData\Local\Programs\Microsoft VS Code\bin"

  9. After modifying the environment variables, restart the computer for those changes to take effect in Windows.

enter image description here

enter image description here