Reputation: 23
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
Upvotes: 2
Views: 5804
Reputation: 343
In my case I had this issue because I was logged in as Administrator instead of my usual user id. Environment variable for path did not include location of VSCode for Administrator user. Updating the path variable fixed the issue.
Upvotes: 0
Reputation: 11
You have to add path to eviroment variable:
Press the Windows key+X to access the Power User Task Menu.
In the Power User Task Menu, select the System option.
In the System window, scroll to the bottom and click the About option.
In the System > About window, click the Advanced system settings link at the bottom of the Device specifications section.
In the System Properties window, click the Advanced tab, then click the Environment Variables button near the bottom of that tab.
In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button.
In de popup windows click the New button.
Enter your path for Visual Studio Code, something like this: "C:\Users{user}\AppData\Local\Programs\Microsoft VS Code\bin"
After modifying the environment variables, restart the computer for those changes to take effect in Windows.
Upvotes: 0
Reputation: 8411
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
.
Upvotes: 2