Create a JavaScript Project in Visual Studio Code

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.

📋 Steps

  1. Open Visual Studio Code.

  2. Open the Explorer Tab and click Open Folder.

  3. Create a new folder or choose an existing one.

  4. In the Explorer, click the New File icon next to the folder name.

  5. Name the file index.js and press Enter.

  6. Open index.js and add a single line: console.log("Hello, World!");.

  7. Save the file:

    • Windows/Linux: Ctrl+S
    • Mac: Cmd+S

🎯 Expected Outcome

  1. The project folder contains a index.js file.
  2. index.js contains 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