VS Code 终端无法输入文字

12
我的 VS code 终端之前一直运行正常,但某天当我尝试在一个仍在 VS code 中打开的项目上工作时,我的终端突然无法输入任何命令。屏幕显示如下:截图。请帮忙解决问题。
14个回答

21

好的,对于那些与我有同样问题的人,我已经通过点击下拉菜单上的 powershell 并将其更改为 cmd 来解决了。


没有cmd选项。 - MercifulSory
如果您使用的是Linux系统,则不会有cmd选项,因为命令提示符仅适用于Windows系统。 - Billy
1
解决了。我一直讨厌PowerShell。 - enes islam

8

这件事情发生在我改变了CMD的默认路径后,简单地解决方法如下:

  1. 关闭VS Code
  2. 右键点击它
  3. 以管理员身份运行
  4. 打开终端,问题即得到解决

完美,这在2021年解决了我的问题! - Ceri Westcott
1
我的问题已解决,在我将 VSCode 更新至版本 1.64.2 后。 - Boat
一直很好,我不想更新VSCode,但出现了这样的问题。然后我看到了@Boat的评论。于是我决定更新到1.77.0(一周前)。结果它起作用了。谢谢。不知道发生了什么。 - Sergo

3
当运行“ionic serve”命令时,我遇到了类似的问题,该命令在本地主机上运行开发服务器。执行上述命令后,我注意到它显示:

使用Ctrl+C退出此进程

按下Ctrl+C后会显示:

终止批处理作业(Y/N)?

输入Y或y

然后命令提示符再次显示!

这里是一个示例终端窗口 - 为简洁起见进行了修剪:

enter image description here

enter image description here


2

对我来说,我尝试使用 Powershell/CMD/Bash,但是出现了错误/空白终端。我发现输入 echo hello 并按下 CTRL + C 使其出现。因此实际上一切都在运行,我的终端只是空白/出现故障,但确实接受输入。


1

如果你在使用React时遇到了这个问题,那么可能是因为你使用npm start启动了实时版本。负责处理应用程序实时版本的终端无法用于其他任何事情。

所以,为了继续使用终端,您需要打开一个新的终端来并行使用。只需单击终端面板右上角的加号图标,然后选择“Power Shell”选项即可。这将在不重新启动Visual Studio的情况下打开一个新的终端。


谢谢,我刚开始学习React,但让我疯狂的是在npm start后需要重新打开VSCode才能在终端中编写代码。 - Omer Bonfil

1

在 Mac 上,使用 Python 时,这个方法对我很有帮助:不要点击“运行代码”选项,而是点击右上角的“运行 Python 文件”。


0
对于Ubuntu用户,这个问题可以通过这个解决方案来解决:
文件 -> 首选项 -> 设置 -> 特性 -> 终端 -> 继承环境

0

如果输入 Ctrl+C 可以帮助您摆脱这种冻结状态,那么在 VSCode 1.64(2022年1月)中执行将更容易。

终端可以为您输入答案。

Terminal -- Auto-reply

The terminal is now able to automatically reply when a specific sequences of characters is received.

A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.

The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.

Pressing Ctrl+C will immediately reply to the question and return to the prompt:

enter image description here

Theme: Sapphire

The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.

For example you could use it to automatically update Oh My Zsh when prompted:

"terminal.integrated.autoReplies": {
 "[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}

If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:

"terminal.integrated.autoReplies": {
 "Terminate batch job (Y/N)": null
}

0
我在桌面上找到了两个 VS Code,我打开了另一个并且它可以正常工作。看起来我更新了其中一个,但是旧的并没有消失。

-1

打开终端,进入首选项和设置。 勾选“在终端中运行代码”。 重新启动VS。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接