There are few different ways to run JavaScript in VSCode Terminal. And it depends on what you really want to do. In this tutorial I’ll drop a video and then for readers I’ll drop some basic instructions on running JS in VSCode.
For some running JavaScript in VSCode means running the entire webapp in a browser. You can do this using extensions like LiveRunner.
But in many cases you just want to execute a single JavaScript file directly in the VSCode terminal. You can do that with NodeJS (make sure it’s installed.)
One way is to use the built-in NodeJS runtime. To do this, open your JavaScript file in VSCode and press F1
or Ctrl+Shift+P
.
This will open the Command Palette.
Then type node
and select the Run Node.js in Terminal
command. Your JavaScript file will be executed in the vscode terminal.
Another way to run javascript files is to use the integrated task runner. To do this open your JavaScript file in VSCode and press Ctrl+Shift+B
(or go to Debug…