How to Run JavaScript in Visual Studio Code

Web Development

Learn how to run JavaScript in Visual studio Code using Node.js npm and VS Code Extensions like ES6 and Code Runner.

Introduction

You just started learning javascript or just want to know how to run JavaScript in Visual Studio Code aka VS Code on Windows or Mac. Well you came to the write place because in this video I am going to teach you how to run JavaScript in VS Code and not only that but you will also learn how to instal and run NodeJS & NPM, instal and run Visual Studio code and also create you very first JavaScript Program and run it in VS Code.

So if you are exited then pls give this video a like. As Always I am Norbert and I teach web development on my channel.

Install Visual Studio Code

Next up you will need to install Visual Studio Code. For this you can visit https://code.visualstudio.com/ and first download the installer. After the download has finished you can now install VS Code. The installation is pretty strate forward

Download NodeJS and NPM

First things first, lets install node.js and npm, for this you need to go to www.nodejs.org and from here, depending if you are on Windows or Mac OS, you can now start downloading node js, don’t worry about npm, it is includied in the standard nodejs installation pakagemanager.

Install and Run NodeJS and NPM

After the download process has finished, you can now start installing npm and nodejs from the installer that you just downloaded. Just click on the installer and the instalattion process should start, also you can open up the installers from it’s location and start the installation process from there by double clicking it.

Now that we have NodeJS and npm installed lets do a quick check if they are really in our system and are up to date.

For this, depending on the operating system you are running. On Windows ou will need to open the command prompt by cliking the windows icon and surch for cmd this launch command prompt. Click on it or press enter and after the command prompt is launched, you can now check for the version of you nodejs by typing node -v or node –version , now to check npm we can do the same thing npm -v or npm –version. If everything is up to date and good to go then you can move on.

Visual Studio Code Extensions for JavaScript

Before you start running JavaScript in Visual Studio Code, you need to install a coplle of esenstial extentsions in order to take benefit of the full power of JavaScript.

The first one is:

  1. JavaScript (ES6) code snippets
    This extension contains code snippets for JavaScript in ES6 syntax for Vs Code editor (supports both JavaScript and TypeScript). In other words it will make you live fahr easeier wen typing your javascript code
  2. Code Runner
    Run code snippet or code file for multiple languages inkl JavaScript so we don’t need the v8 engine from the browser

Run your first JavaScript Code in Visual Studio Code

console.log("Subscribe to my channel");
Now lest open up the integrated terminal in VS Code and now, click on the play button in the upper right corner in orther to run your code

Code for this tutorial

// console.log("Subscribe to my Channel")

let subscribe = "Subscribe to my Channel";
subscribe = "Subscribe to my Channel";
const channelName = "NorbertBM";

function subscribeTo() {
  return `${subscribe} ${channelName} Web Development`;
}
// console.log(subscribe +" " +channelName)

console.log(subscribeTo());

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.