Error when running code .
command in Terminal on macOS
#VSCode#Terminal
If you encounter the "code: command not found" error when running the code .
command in the terminal:
- Check if your code editor is located in the Applications folder. If not, move it there.
- Add $PATH to the
~/.zshrc
(or~/.bash_profile
) file and runsource ~/.zshrc
to restart the terminal.
You can obtain the path to code
by using the command which code
Here's an example of PATH to add to the ~/.zshrc
file:
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
You can also add the path in VSCode from the Command Palette by running the Shell Command: Install 'code' command in PATH command.