How to Run JavaScript in Visual Studio Code on Windows 11 / Windows 10 | JavaScript in VSCode

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video I'm going to show you how you can add the JavaScript support in your Visual Studio code editor so essentially I'm going to show you how you can run a JavaScript code in your Visual Studio code editor so hopefully you have already installed Visual Studio code now in order to run JavaScript code inside your Visual Studio code or any operating system you need a tool called node.js node.js is a JavaScript framework which will allow you to create web applications in JavaScript right so if you install node.js you will be able to run JavaScript code also in order to install node.js just open your favorite browser and search for node.js and the first link which will appear here will be from node.js so I'm going to click on this link at the time of making this video uh these are the two versions I always go with LTS version LTS stands for long term support versions right so they have the support for longer term so just choose the version which says LTS in front of it at the time of making this video 18.15.0 is the latest version so let me click on this button which will download this node.js MSI file so I'm going to click on this MSI file once it's downloaded and I'm going to just minimize my browser here so you can see the node.js setup wizard has been started on this window just click on next here click on I accept the term slices agreement click on next this will be the default location where node.js will be installed so if you don't have the good reason to change this just leave it as default and then click on next and then click on next and then you can see automatically install necessary tools so for now I don't want to install additional tools but later on you can install these additional tools for node.js right I'm going to click on next and then click on install and then click on yes which is going to install node.js on my Windows operating system so just wait for this progress bar to reach to the 100 Mark and once that's done you can see completed node.js Setup Wizard click on finish and node.js is installed on your Windows operating system to check whether it's installed correctly you can just type CMD in Search and then click on command prompt and then just type node and then press enter which is going to open this node rapple which stands for read a well print Loop here you can write a very simple JavaScript code for example console DOT log and I can print something here okay so let me print hello World here and then press enter and it prints hello worlds so this is essentially the JavaScript code which you are running with the help of this node.js tool now let's open our Visual Studio code editor and here I can open a folder or let me show you one more thing so let's say I have this Javascript app folder on my desktop where I want to create my JavaScript files here I can open this folder and then right click here once Visual Studio code is installed click on show more options and then click on open with code and then this folder will be opened in your Visual Studio code editor now you can also open as command prompt so just once again go here right click and then open in a terminal and you can just CD into the folder in which you want to create a Javascript file and then type code space Dot and then press enter which is also going to open the JavaScript folder or whatever folder you want to open in Visual Studio code now let's create a Javascript file so I'm going to just click on this plus sign and then just type test dot JS okay and you can see this file is created so I can just type console DOT log and then I can just write hello World here so you can see Visual Studio code is going to provide you the intellisense also just save your file and in order to run your file you can open the terminal from the top so just click on Terminal and then click on new terminal and from here you can see the Powershell is open you can also open command prompt from here so click on command prompt and because we have installed node we can use node to run our Javascript file so I'm going to just write test dot JS after node so node space the name of the file which is test.js in my case and it prints hello world on Powershell if you select the Powershell here you can just write node and then the name of the file or whatever is the name of the file and then press tab here which is going to auto complete your file name so you can see it has Auto completed and on Powershell you just write dot backslash or in front of file name right so once again just press enter and it prints hello world so this is how you can run the JavaScript code using the terminal but in Visual Studio code you can also install some cool extensions to run your code so one such extension is code Runner so just search for code Runner here so just select this extensions tab first of all so you can see there is this extension Tab and then just search for code Runner and then select this first option which is called code Runner and it has around 18.6 million download so it's a very popular extension so just click on install to install this extension and once this extension is installed you can see you can uninstall or disable this extension later also once this that is installed I can close this window and as soon as I have installed this code Runner extension I can see this run code icon in front of the file right so on top right you can see this new option to run your JavaScript code so when you click on this run code option you will be able to see your code will be run automatically you don't need to type anything on the terminal it will run automatically right so let me add a few more options and then save my code and then I can rerun it and it will rerun my code and it prints hello world with all these symbols right now if you want to create more complex programs let me show you how you can do it so for example if you want to create a node.js server you can find this code anywhere on internet just search for how to create a simple node.js server and this code you will find there right and this is a JavaScript code and what it does is it creates a server which you can run on your browser and it's going to show you the hello world output right so let me just run this code and once it's running you can see it says server running at this IP address and this port so I'm going to just copy this or I can just control and click on this okay so control press Ctrl key and then click on this uh link which is going to open this on your browser so let me just paste this link and then it prints hello world as you can see here so you can even create some server code which is also written in JavaScript as you can see test dot JS right so this is how you can run the JavaScript code on your Visual Studio code editor Additionally you can install many JavaScript related extension so just type Java script here and then press enter and you will see many JavaScript related extensions so you can install all these popular extensions you can see this extension is downloaded 11 million times so this is very popular right and then you have this tribe script extension JavaScript debug extension so you can install all these extensions and all these extension will help you to develop your code and run your code efficiently okay so I hope you enjoyed this video and I will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 110,718
Rating: undefined out of 5
Keywords: how to run javascript in visual studio code mac, how to run js file in vs code terminal, how to run html and javascript in visual studio code, how to run javascript code, how to install node js in visual studio code, how to run javascript in terminal, how to run javascript in windows 10
Id: LqXzpj2jfOU
Channel Id: undefined
Length: 10min 4sec (604 seconds)
Published: Fri Apr 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.