WSL and NPM: npm ERR! Error: EACCES: permission denied

Have you tried installing an NPM package and have been presented with errors similar to “npm ERR! Error: EACCES: permission denied”?
Chances are likely that you are using WSL (Windows Subsystem for Linux) and issuing commands from within VSCode terminal emulator.

Sadly, I will be unable to give you instructions on how to fix this. However, it seems to only occur whilst using the VSCode Terminal connected to a WSL.

To get around this, I have found that closing VSCode (all VSCode instances that are connected to the WSL) and issuing the command through the “app” terminal instead. You should now be able to install as normal!

Windows, VS Code, Git and SSH Authentication with passphrases

Have you spent the past several hours frantically searching the web for a solution of integrating Git with VSCode? Are you tempted to remove passphrases from your SSH Key just to get around Permission denied (publickey) errors every time you try and clone a repo?

Yes, it is disappointing that there is no clear documentation for this.
Hopefully, this will fill the gap.


Windows 10
Git installed
VSCode installed
Created an SSH key using the Git terminal and is passphrase protected.
Added your SSH public key to your chosen Git Service.


Before starting VSCode, open up a new Windows CMD window.
Enter the command: start-ssh-agent and you will be prompted to provide the passphrase to your SSH Key.

cmd start-ssh-agent

Now you will be able to open VSCode and clone into your repository.


If you wanted to automate start-ssh-agent and open VSCode at the same time, I have built a batch script that will do just this.

Open text editor and paste in the code below. Save file as VSCode_ssh-agent.bat

I decided to place this file in my Windows home directory. On the Desktop, I created a shortcut to the .bat file and set the icon to point to:

C:\Users\[USER]\AppData\Local\Programs\Microsoft VS Code\Code.exe

The final result:

  1. Check if SSH-AGENT is running.
    If not, start SSH-AGENT and ask for the passphrase for your key.
  2. Start VSCode