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

2023-12-24

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

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

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

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

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

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


For an overview of all types of shells used in Visual Studio Code, see this answer https://stackoverflow.com/a/60555493/45375.

Custom shell profiles are maintained in the settings.json file; to open it for editing, select Preferences: Open Settings (JSON) from the command palette (Ctrl-Shift-P).

特定于平台的属性命名为terminal.integrated.profiles.*, where *或者是windows, linux, or osx(苹果系统)。

The properties inside each define shell profiles, i.e. the shells available for running in the integrated terminal via the dropdown menu labeled + (shell-selection dropdown).

Each 外壳配置文件定义:

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

  • 启动参数通过指定args.

  • 有关所有支持的属性,请参阅the docs https://code.visualstudio.com/docs/editor/integrated-terminal#_configuring-profiles.

To set the default外壳轮廓:

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

    • Note: Clicking the cog icon (cog icon) to the right of each profile allows you to define a new profile that is a based on the highlighted one: You're prompted for a name for the new profile, which is then created as a copy of the highlighted profile. Note that no further action is taken as of v1.59 - you must manually open the settings.json file for editing in order to customize the new profile.
  • Or:设置适合平台的terminal.integrated.defaultProfile.*属性到所需 shell 配置文件的名称。


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

  • 确定完整路径node.exe并逃脱\JSON 的字符加倍;例如,从 PowerShell:
# Get node.exe's full path, escape '\' chars., copy to the clipboard.
(Get-Command node.exe).Path.Replace('\', '\\') | Set-Clipboard
  • 将以下内容添加到您的settings.json文件(如果terminal.integrated.profiles.windows财产已经存在,简单地说add the 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",
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何添加节点终端Visual Studio Code? 的相关文章

随机推荐