Setup: Install VS Code

Install Visual Studio Code with winget, then open it, a file, or a whole folder from the terminal.

Novice · Operating System · Software Development · Updated

After this lesson you can

  • Install an app with winget
  • Open a file in VS Code from Windows Terminal

Key takeaways

  • winget install -e --id followed by a package's id installs that app, such as Microsoft.VisualStudioCode for VS Code.
  • A terminal learns about new commands only when it starts, so close Windows Terminal and open it again after every install.
  • code --version checks that the code command works. code opens VS Code, code . opens the folder you are in, and code with a file name opens that file.

Windows only. VS Code is the editor you will use for HTML, CSS, and JavaScript. Git will also use it whenever it needs you to write a message. Install it before Git, so the Git installer can find it.

Install VS Code

Watch the video on YouTube

In Windows Terminal (PowerShell), run:

winget install -e --id Microsoft.VisualStudioCode

This command tells WinGet what to install:

  • install installs an application.
  • --id Microsoft.VisualStudioCode identifies the application by its package ID.
  • -e (short for --exact) requires the package ID to match exactly, including capitalization.

winget downloads and installs VS Code. You should see Successfully installed at the end.

The installer also adds a code command to your terminal. A terminal only learns about new commands when it starts, so close Windows Terminal completely and open it again. You will do this after every install.

Choosing installation options

Some installers let you make choices, such as selecting adding Open with Code to the File Explorer's context menu. To launch the installer’s own windows, add -i, short for --interactive:

winget install -e --id Microsoft.VisualStudioCode -i

For example, when installing Git this way, you can choose its default editor as you work through the installer.

WinGet has other installation options, too. For example, --version lets you request a specific version, and --silent requests an installation without installer windows. To see the available options, run:

winget install --help

Check your work

In the new Windows Terminal window, run:

code --version

You should see three lines: a version number such as 1.142.0, a long code made of letters and numbers, and x64.

Now start VS Code from the terminal:

code

VS Code opens. You can also find it in the Start menu as Visual Studio Code. Close it again.

You can also give code something to open. code . opens the folder you are in, and code notes.txt opens the file notes.txt from that folder. If there is no such file yet, VS Code opens an empty one and creates the file when you save it. You will open your project folders this way all through the course.

Common problems

What you see What to do
code : The term 'code' is not recognized Close every Windows Terminal window, then open a new one. If it still fails, sign out of Windows and back in.
Found an existing package already installed VS Code was already installed. That is fine. Continue with Check your work.

Check yourself

2 questions to try on the lesson page.

So what

Most Setup exercises after this one follow the same pattern: one winget command, a fresh terminal, then a version check. And code . is how you will open almost every project you work on.

Key terms