DEV Community

Cover image for Run JavaScript In VSCode
Code Something
Code Something

Posted on

3 1

Run JavaScript In VSCode

Hey guys! So just been posting several of my coding tutorials in a row that I've been working on for a while.

I like to spend time writing and editing my content. So I usually record a video along with a blog post.

VSCode is absolutely my favorite IDE. (I switched from IntelliJ/Idea WebStorm which used to be my first IDE, but their UI is just too slow for me) I use it for pretty much all coding for work and personal projects.

Running JavaScript From Terminal in VSCode

If you're working on a JavaScript project in VSCode, you might want to run your JavaScript files directly from the terminal.

Below are some videos that can help you get started fast.


How To Run JavaScript In VSCode Video #1


How To Run JavaScript In VSCode Video #2

Luckily, Visual Studio Code makes it easy to do this. All you need to do is open up your terminal (Ctrl+`), and then type the following:

> node {filename}

Replace {filename} with the name of your javascript file. For example, if your file is named "script.js", you would type:

> node script.js

This will run your javascript file and show any output in the terminal window.

Keep in mind that you can also use this method to run javascript files that are located in a different directory. To do this, simply type the path to the file before the filename. For example:

> node C:/Users/username/Desktop/script.js

This would run the javascript file "script.js" that is located on your Desktop.

You can also use relative paths to run javascript files that are located in different directories. Relative paths are based on the current location of your terminal. So, if your javascript file is located in a folder called "js" that is in the same directory as your terminal, you could run it by typing:

> node js/script.js

This would run the javascript file "script.js" that is located in the "js" folder.

You can also use the "../" notation to go up one directory. So, if your javascript file is located in a folder called "js" that is in the parent directory of your terminal, you could run it by typing:

> node ../js/script.js

This would run the javascript file "script.js" that is located in the "js" folder.

Hopefully this helps you run javascript files from the vscode terminal!

Neon image

Set up a Neon project in seconds and connect from a Next.js application

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →

Top comments (0)

Neon image

Next.js applications: Set up a Neon project in seconds

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay