无法运行命令 "install code command in PATH"

17 浏览
0 Comments

无法运行命令 "install code command in PATH"

我正在使用Visual Studio Code,但我无法运行“将代码命令安装到路径中”的选项,因为当我按下Shift + Ctrl + P时,该命令不会出现。我正在使用Windows 10和最新版本的Visual Studio Code。\n我尝试了很多步骤来解决我的问题,但都没有成功。以下是我所做的:\n

    \n

  1. 重新安装了Visual Studio Code(最新版本),并选中了添加到PATH变量的选项。没有起作用。
  2. \n

  3. 打开环境变量并编辑了Path用户变量,重新启动计算机。没有起作用。
  4. \n

  5. 打开命令提示符并输入code .。没有起作用。
  6. \n

\n接下来我该怎么办?

0
0 Comments

Windows系统默认安装了VS Code,无需添加路径。只需在命令提示符中运行"code ."即可正常工作。

However, if you encounter the error message "Can't run the command 'install code command in PATH'", it means that the 'code' command is not recognized in the command prompt. This error can occur due to the following reasons:

1. The installation of VS Code may have been corrupted or incomplete.

2. The 'code' command is not added to the system's PATH environment variable.

To resolve this issue, you can follow the below steps:

1. Reinstall VS Code: First, uninstall the existing installation of VS Code from your system. Then, download the latest version of VS Code from the official website and install it again.

2. Add 'code' command to PATH: If reinstalling doesn't solve the issue, you need to manually add the 'code' command to the system's PATH environment variable.

- Open the Start menu and search for "Environment Variables".

- Click on "Edit the system environment variables".

- In the System Properties window, click on the "Environment Variables" button.

- Under the "System variables" section, scroll down and find the "Path" variable. Select it and click on the "Edit" button.

- In the Edit Environment Variable window, click on the "New" button and add the path to the 'bin' folder of the VS Code installation directory. The default installation path is typically "C:\Program Files\Microsoft VS Code\bin".

- Click "OK" to save the changes and close all the windows.

After following these steps, reopen the command prompt and try running the "code ." command again. The error message should no longer appear, and you should be able to use the 'code' command to open VS Code from the command prompt.

请注意,对于不同的系统和安装方式,VS Code的安装路径可能会有所不同。因此,在将路径添加到环境变量时,请根据您的实际安装路径进行调整。

希望这篇文章对您解决"Can't run the command 'install code command in PATH'"的问题有所帮助!

0
0 Comments

当使用 Visual Studio Code 时,如果出现以下情况:

  1. 无法运行 code . 命令
  2. 在 Visual Studio Code 中找不到 "install code command in path"

可以通过在 Git 中使用以下命令手动将 VS Code 添加到路径中:

cat << EOF >> ~/.bash_profile
# 添加 Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF

然后打开一个新的终端以使 .bash_profile 的更改生效。

注意:在连接时需要添加斜杠 \,以防止 $PATH 在连接过程中被展开。如果想要直接在终端中运行 export 命令,则需要去除斜杠。

注意:由于在 macOS Catalina 中,zsh 变为默认 shell,因此需要运行以下命令将 VS Code 添加到路径中:

cat << EOF >> ~/.zprofile
# 添加 Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF

0