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

编程入门 行业动态 更新时间:2024-10-04 09:22:19

如何添加节点<a href=https://www.elefans.com/category/jswz/34/1771374.html style=终端Visual Studio Code?"/>

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

我还没有成功,但是我重新安装了我的 Visual Studio 代码,并且无法再次向它添加节点终端。

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

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

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

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

对不起,如果解释很多,但我想非常清楚...

回答如下:

有关 Visual Studio Code 中使用的all shell 类型的概述,请参阅this answer。

自定义外壳配置文件保存在

settings.json
文件中;要打开它进行编辑,请从命令面板 (
Ctrl-Shift-P
) 中选择Preferences: Open Settings (JSON)

特定于平台的属性名为

terminal.integrated.profiles.*
,其中
*
windows
linux
osx
(macOS)。

每个内部的属性定义shell配置文件,即可通过标记为+

)的下拉菜单在集成终端中运行的shell。

每个shell-profile定义

  • 至少需要一个

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

  • 启动参数通过

    args
    指定。

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

设置默认外壳配置文件

  • Either:使用命令面板中的

    Terminal: Select Default Profile
    命令:将显示所有已定义配置文件的列表;选择一个感兴趣的。

    • 注意:单击每个配置文件右侧的齿轮图标 () 允许您定义一个 new 配置文件,它是 基于 突出显示的配置文件:系统会提示您为新配置文件命名,然后将其创建为突出显示的配置文件的copy。请注意,自 v1.59 起未采取进一步操作 - 您必须手动打开
      settings.json
      文件进行编辑才能自定义新配置文件。
  • :将适合平台的

    terminal.integrated.defaultProfile.*
    属性设置为所需外壳配置文件的名称。


示例:在 Windows 上将 Node.js (

node.exe
) 定义为自定义 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
    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",

更多推荐

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

本文发布于:2024-05-30 23:49:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:终端   节点   Visual   Studio   Code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!