如何添加节点终端Visual Studio Code?

Mil*_*ics 8 powershell node.js visual-studio-code

我尚未成功,但我重新安装了 Visual Studio Code,并且无法再次向其中添加节点终端。

请不要说我也可以使用 bash 运行并使用 powershell。这两个在Vscode中默认可达。

但我想更改默认终端并更改为节点终端。不是 powershell 也不是 cmd...

我在这个主题上搜索了很多网站,但都没有找到解决方案。有解决办法。我今天在 vs code 中使用了节点终端。

所以我应该看到节点而不是 powershell 或 cmd。

抱歉,如果解释很多,但我想非常清楚......

在此输入图像描述

mkl*_*nt0 9

有关 Visual Studio Code 中使用的所有类型 shell的概述,请参阅此答案

自定义 shell 配置文件保存在settings.json文件中;要打开它进行编辑,请Preferences: Open Settings (JSON)从命令选项板 ( Ctrl-Shift-P) 中进行选择。

有一些名为的特定于平台的属性terminal.integrated.profiles.*,其中*windowslinuxosx(macOS)。

每个定义外壳配置文件内的属性,即可通过标记为(的下拉菜单)在集成终端中运行的外壳+shell选择下拉菜单)。

每个shell-profile 定义

  • 至少需要一个path指定 shell 可执行文件的完整路径的参数,或者仅在 Windows 上需要一个source参数,该参数可以是PowerShellGit Bash让 VS Code 找到适当的可执行文件。

  • 启动参数通过 指定args

  • 有关所有支持的属性,请参阅文档

设置默认shell 配置文件

  • 要么:使用Terminal: Select Default Profile命令面板中的命令:将显示所有定义的配置文件的列表;选择感兴趣的一项。

    • 注意:单击齿轮图标 (齿轮图标)位于每个配置文件右侧,允许您定义一个基于突出显示的配置文件的配置文件:系统会提示您输入新配置文件的名称,然后将其创建为突出显示的配置文件的副本。请注意,自 v1.59 起不再采取进一步操作 - 您必须手动打开文件进行编辑才能自定义新配置文件。settings.json
  • 或者:将适合平台的terminal.integrated.defaultProfile.*属性设置为所需 shell 配置文件的名称。


示例:在 Windows 上将 Node.js ( ) 定义node.exe为自定义 shell 配置文件:

  • 通过将 JSON 字符加倍来确定 JSON 的完整路径node.exe和转义字符;\例如,来自 PowerShell:
# Get node.exe's full path, escape '\' chars., copy to the clipboard.
(Get-Command node.exe).Path.Replace('\', '\\') | Set-Clipboard
Run Code Online (Sandbox Code Playgroud)
  • 将以下内容添加到您的settings.json文件中(如果该terminal.integrated.profiles.windows属性已存在,只需将属性添加Node.js到其中即可);该示例使用 的node.exe默认安装位置C:\Program Files\nodejs\node.exe
"terminal.integrated.profiles.windows": {
    "Node.js": {
      "path": "C:\\Program Files\\nodejs\\node.exe",
      "args": [] // Add startup arguments as needed.
    }
  },

// Make Node.js the default shell (if the property already exists, update its value).
"terminal.integrated.defaultProfile.windows": "Node.js",
Run Code Online (Sandbox Code Playgroud)