As a regular user of Visual Studio Code (VSCode) on macOS, you may be wondering why opening VSCode from the terminal does not work as expected:
zsh: command not found: code” means that the shell (in my case zsh, in your case maybe bash) is not able to find the
code executable. This might confuse you if VSCode is already installed on your system.
There are two solutions to this problem.
Plan A: You can execute the following command:
ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
This creates a symbolic link to the code executable in a directory where your shell usually looks for executables (
/usr/local/bin/code). That’s it – you should now be able to use
code . as expected.
Plan B: If the above command is not working for some reason, you can use VSCode’s UI to accomplish the same thing. Press Command-Shift-P, enter “shell” and select “Shell Command: Install ‘code’ command in PATH”.
Again, that’s it. Run
code /path/to/some/directory to open a folder in VSCode and have fun programming!