Setup: Install VS Code

Install Visual Studio Code with Homebrew and open files in it from the terminal.

Novice · Operating System · Software Development · Updated

By

After this lesson you can

  • Install an app with a Homebrew cask
  • Open a file in VS Code from the terminal

macOS 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 VS Code

In the Terminal, run:

brew install --cask visual-studio-code

Homebrew downloads VS Code, puts it in your Applications folder, and adds a code command to your terminal.

Open it once

Open Applications in Finder and double-click Visual Studio Code. If macOS says the app was downloaded from the internet and asks whether you want to open it, click Open.

Close VS Code again when it has finished opening.

Check your work

In the Terminal, 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 arm64 or x64.

Now open a file from the terminal:

code ~/.zprofile

VS Code opens the file you changed in the Homebrew exercise. On a Mac with an Apple chip, you should see the eval line you added. On an Intel Mac, which skipped that step, the file is empty, and that's fine: VS Code opening it is the check. Close the file without changing it.

Common problems

What you see What to do
zsh: command not found: code Open a new terminal window. If it still fails, open VS Code, press Command+Shift+P, type shell command, and choose Shell Command: Install 'code' command in PATH.
It seems there is already an App at '/Applications/Visual Studio Code.app' VS Code was already installed. That is fine. Continue with Check your work.