
For example, if your file name is app.js, write node app.js click enter key to see the JavaScript output.

Open the JavaScript file that you want to run it.Download and install Node.js on your computer.Here are the steps to run JavaScript with Node.js:

This method will let you run JavaScript files directly on the text editor’s terminal, and no need to switch windows like in method 1. Method 2: Use Node.jsĪnother way to run JavaScript in VS Code is using Node.js. Unless you’re working on smaller windows or have two monitor screens, this will inconvenience you a little bit. The only downside of using this approach is you will constantly switch between a browser and VS Code windows. In the Inspect Window, click the Console tab, and this is where you can see the JavaScript outputs.You can also open it by clicking Ctrl + Shift + I keys for Windows, or Cmd + Option + I keys for Mac. In the browser, open the inspect window by right-clicking the mouse and select Inspect option.Save the changes and then open the HTML file in the browser.You can write JavaScript code inside the script tags. Create an HTML file in VS Code and inside the file, add the script tags.

This method is straightforward as you only need VS Code and a browser of your choice to view JavaScript outputs. The simplest way to run JavaScript in VS Code is to create an HTML file.

There are three ways you can run JavaScript in the text editor and for that, feel free to choose whatever suits you the best. In this short tutorial, you will learn how to run JavaScript in Visual Studio Code.
