Milán Nikolics
Milán Nikolics

Reputation: 621

How to add node terminal Visual Studio Code?

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 i should see node instead powershell or cmd.

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

enter image description here

Upvotes: 9

Views: 26974

Answers (1)

mklement0
mklement0

Reputation: 440431

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 + (shell-selection dropdown).

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 (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",

Upvotes: 10

Related Questions