skip to Main Content

Everytime I run a javascript code, a new terminal gets created. I would so much prefer this not to happen and just make use of my default terminal which is PowerShell.
In a nutshell this is how my workspace has been configured:

{
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\Sysnative\cmd.exe",
                "${env:windir}\System32\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },
        "Git Bash": {
            "source": "Git Bash"
        },
        "Windows PowerShell": {
            "path": "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
        }    
    "code-runner.runInTerminal": true,
    "code-runner.clearPreviousOutput": false,
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    }
}

What I tried is;

{
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "clear; cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "clear; cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    }
}

I expected the code to work with my default terminal PowerShell but it still created another terminal named code.

2

Answers


  1. Chosen as BEST ANSWER

    Found my answer on this; In VSCode, Python debugger launches a new Terminal every time I debug

    It was made for python but also worked for me. I need a launch.json file with the configurations as below;

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "Javascript: new1.js",
                "skipFiles": [
                    "<node_internals>/**"
                ],
                "program": "${file}",
                "console": "integratedTerminal",
                "args": ["&&", "exit"]
            }
        ]
    }
    

    Hope this helps the next javascript user.


  2. It looks like you are using the Code Runner extension in Visual Studio Code, and you want to run JavaScript code in your default PowerShell terminal instead of creating a new terminal named "code."

    You can achieve this by configuring the Code Runner extension to run the code in the integrated terminal. Make sure the "code-runner.runInTerminal" setting is set to false. Also, you can remove the "code-runner.executorMap" configuration for JavaScript, as it’s not necessary to specify a custom executor for JavaScript.

    By setting "code-runner.runInTerminal": false, Code Runner should now execute JavaScript code in the integrated terminal instead of creating a new one.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search