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
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;
Hope this helps the next javascript user.
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.