The quickest way to open a folder in VS Code is by using thecodecommand in Terminal. But if you haven’t configured it correctly, you might encounter a “zsh: command not found: code” error. Follow these two steps to fix it.
1. Reinstall Visual Studio Code
Usually, the recommendedway to install software on a Macis via the App Store. However, since VS Code isn’t available on the App Store, downloading it fromVisual Studio Code’s official siteis your only option.
Even if you did that already, you might still be running the app from theDownloadsfolder in macOS. So make sure you move the executable file to theApplicationsfolder instead.

2. Install the Code Command to PATH Variables
After moving VS Code to your Applications folder, you must add thecodecommand to your PATH variables. Once the command is in your PATH environment variables, you’re able to run it from the Terminal app in macOS.
Luckily, you don’t have to fiddle with the command line to do so. VS Code provides a one-click solution to add the command to your PATH variables, by doing the following:

Once done, a “Shell command ‘code’ successfully installed in PATH” dialog will appear. Now, even if you don’tknow your way around the Mac Terminal, you can quickly open a folder in macOS by using thecodecommand. Justopen Terminal on your Macand navigate to the folder using thecdcommand. Once you’re in the folder of interest, enter “code .” in Terminal and pressReturn(orEnter).
As one of the best free code editors, VS Code provides a wide array of features that make it easy to develop and debug software. If you prefer using Terminal to navigate your file system, thecodecommand makes it easy to open the current folder in the editor.