🛠️ Quickly Launch VSCode from Terminal as Admin (2023)

Easily open VSCode in a desired directory using the terminal by running it as an administrator with this simple solution.


about 2 months ago

I wanted to utilize the code . command in the terminal to directly open VSCode in my desired directory. To achieve this, I navigated to the VSCode Command Palette and chose >Shell Command: Install 'code' command in PATH. However, I encountered an error message stating "permissions denied" and that administrator access was required for this action.

After some searching, I discovered several solutions to run VSCode as an administrator. The following command was the only one that worked for me:

$ sudo /Applications/Visual Studio Code.app/Contents/MacOS/Electron; exit

Upon executing this command, VSCode should open, allowing you to select the >Shell Command: Install 'code' command in PATH option.


Bart Stefański

A self-taught full-stack software engineer based in Poland, working in Next.js & Nest.js Stack. Passionate about Clean Code, Object-Oriented Architecture and fast web.