powershell VS代码未从终端打开代码.命令在windows 11

vwkv1x7d  于 2023-04-12  发布在  Shell
关注(0)|答案(2)|浏览(110)

当我尝试从windows终端用“code .”命令打开时,它会抛出一个错误。

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

之前开得很好。不知道发生了什么。我试着重新安装,问题仍然存在

monwx1rj

monwx1rj1#

CMD中where code的结果是什么?如果在默认位置安装VSCode,则应该是C:\Program Files\Microsoft VS Code\bin\codeC:\Program Files\Microsoft VS Code\bin\code.cmd
请将code的父文件夹路径添加到Path的系统环境中。

kg7wmglp

kg7wmglp2#

你必须添加路径到eviroment变量:
1.按Windows键+X访问“Power User Task Menu(高级用户任务菜单)”。
1.在Power User Task Menu(高级用户任务菜单)中,选择System(系统)选项。
1.在“System(系统)”窗口中,滚动到底部,然后单击“About(关于)”选项。
1.在系统〉关于窗口中,单击设备规格部分底部的高级系统设置链接。
1.在系统属性窗口中,单击高级选项卡,然后单击该选项卡底部附近的环境变量按钮。
1.在“环境变量”窗口(如下图所示)中,突出显示“系统变量”部分中的“路径”变量,然后单击“编辑”按钮。
1.在弹出窗口中,单击“新建”按钮。
1.输入Visual Studio Code的路径,类似于以下内容:“C:\Users{user}\AppData\Local\Programs\Microsoft VS Code\bin”
1.修改环境变量后,重新启动计算机以使这些更改在Windows中生效。

相关问题