This procedure walks you through creating a new JavaScript project in Visual Studio Code.
🧰 Prerequisites
Set up both before continuing. The steps below assume they are already in place.
- Node.js installed
- Visual Studio Code installed
📋 Steps
-
Open Visual Studio Code.
-
Open the Explorer Tab and click Open Folder.
-
Create a new folder or choose an existing one.
-
In the Explorer, click the New File icon next to the folder name.
-
Name the file
index.jsand press Enter. -
Open
index.jsand add a single line:console.log("Hello, World!");. -
Save the file:
- Windows/Linux:
Ctrl+S - Mac:
Cmd+S
- Windows/Linux:
🎯 Expected Outcome
- The project folder contains a
index.jsfile. index.jscontains a single line:console.log("Hello, World!");
⚠️ Mistakes
No folder open before creating the file
Creating index.js without a folder open in VS Code leaves the file with nowhere to live, and it may be lost or saved somewhere unexpected. Always open a folder first via File → Open Folder before adding any files.
Naming the file something other than index.js
Any .js filename works technically, but this course expects the file to be named index.js. A different name means the course steps that follow will not match what you see on screen.
Node.js not installed
VS Code lets you write JavaScript, but it does not include Node.js, which is what actually runs it. Without Node.js, the file will still be created, but it cannot run when the course reaches that step. Install it from nodejs.org (external link) first.
📚 Resources
- Working with JavaScript in VS Code (external link), official guide
- Node.js downloads (external link), official site