Windows 中的 Visual Studio Code 命令无法正常工作 [英] Visual Studio Code command in Windows not working properly
问题描述
我的问题是,在 Windows 上手动将其添加到 PATH 时,如何使 VS Code 命令行正常工作?
My question is, how can I make the VS Code command line work properly when manually adding it to PATH on Windows?
在 Visual Studio Code 中,我首先尝试使用复选框安装到 PATH"来安装它,但是当我在命令提示符下键入 code
时,它说命令无法识别.所以我手动编辑了 PATH
并添加了 C:\Program Files (x86)\Microsoft VS Code
.
Inside of Visual Studio Code, I first tried to install it with the tickbox "install to PATH", but when I typed code
in the command prompt, it said command not recognized. So I manually edited PATH
and added C:\Program Files (x86)\Microsoft VS Code
.
但是,当运行以下命令时:
However, when running commands such as:
code -v
命令提示符不打印任何内容,而是启动 Visual Studio Code.
the command prompt doesn't print anything, but launches Visual Studio Code instead.
推荐答案
你的路径环境变量应该包括 C:\Program Files (x86)\Microsoft VS Code\bin
而不是 C:\Program Files (x86)\Microsoft VS Code
(注意最后添加的\bin
).
Your path environment variable should include C:\Program Files (x86)\Microsoft VS Code\bin
instead of C:\Program Files (x86)\Microsoft VS Code
(notice the added \bin
at the end).
bin
子目录提供批处理文件code.cmd
,它在从父目录启动code.exe
之前处理命令行.命令行需要通过批处理文件才能正常工作.
The bin
sub directory provides the batch file code.cmd
, that processes the command line before launching code.exe
from the parent directory. Going through the batch file is required for the command line to work properly.
这篇关于Windows 中的 Visual Studio Code 命令无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!