如何添加节点终端 Visual Studio Code? [英] How to add node terminal Visual Studio Code?

查看:29
本文介绍了如何添加节点终端 Visual Studio Code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有成功,但我重新安装了我的 Visual Studio Code 并且无法再次向其中添加节点终端.

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

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

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

所以我应该看到 node 而不是 powershell 或 cmd.

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

解决方案

有关在 Visual Studio Code 中使用的所有类型外壳的概述,请参阅).

每个shell-profile定义:

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

  • 启动参数通过 args 指定.

  • 有关所有支持的属性,请参阅) 在每个配置文件的右侧允许您定义一个 配置文件,该配置文件是基于 突出显示的:系统会提示您输入新配置文件的名称,然后将其创建为突出显示配置文件的副本.请注意,自 v1.59 起不再采取进一步措施 - 您必须手动打开 settings.json 文件进行编辑,以便自定义新配置文件.

  • :将适合平台的 terminal.integrated.defaultProfile.* 属性设置为所需的 shell 配置文件的名称.


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

    • 确定 node.exe 的完整路径,并通过将 \ 字符加倍来转义 JSON;例如,来自 PowerShell:

    #获取node.exe的完整路径,转义'\'字符,复制到剪贴板.(Get-Command node.exe).Path.Replace('\', '\\') |设置剪贴板

    • 将以下内容添加到您的 settings.json 文件中(如果 terminal.integrated.profiles.windows 属性已经存在,只需添加Node.js 属性);该示例使用 node.exe 的默认安装位置,C:\Program Files\nodejs\node.exe.

    terminal.integrated.profiles.windows":{Node.js":{路径":C:\\Program Files\\nodejs\\node.exe",args": []//根据需要添加启动参数.}}//使 Node.js 成为默认 shell(如果该属性已存在,则更新其值).terminal.integrated.defaultProfile.windows":Node.js"

    I yet succed this yet but I reinstall my Visual Studio Code and can't add node terminal to it again.

    Please not say me I can run with bash also and use powershell. This two default reachable in Vscode.

    But I would like change the deafult terminal and change to node terminal. Not powershell and not cmd...

    I search very lot of website in this topic but vanish the solution. There is solution. I used at today node terminal in vs code.

    So sholud i see node instead powershell or cmd.

    Sorry if explain lot of but I want be very clear...

    解决方案

    For an overview of all types of shells used in Visual Studio Code, see this answer.

    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).

    There are platform-specific properties named terminal.integrated.profiles.*, where * is either windows, linux, or osx (macOS).

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

    Each shell-profile definition:

    • At a minimum requires either a path argument specifying the full path to the shell executable or, on Windows only, a source argument, which can be PowerShell or Git Bash to let VS Code find the appropriate executables.

    • Start-up arguments are specified via args.

    • For all supported properties, see the docs.

    To set the default shell profile:

    • Either: use the Terminal: Select Default Profile command from the command palette: a list of all defined profiles will present; select the one of interest.

      • Note: Clicking the 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: Set the platform-appropriate terminal.integrated.defaultProfile.* property to the name of the desired shell profile.


    Example: Defining Node.js (node.exe) as a custom shell profile on Windows:

    • Determine the full path to node.exe and escape \ characters for JSON by doubling them; e.g., from PowerShell:

    # Get node.exe's full path, escape '\' chars., copy to the clipboard.
    (Get-Command node.exe).Path.Replace('\', '\\') | Set-Clipboard
    

    • Add the following to your settings.json file (if the terminal.integrated.profiles.windows property already exists, simply add the Node.js property to it); the example uses node.exe's default installation location, 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆