Any ideas on how to get 'npm audit' working in the Windows Subsystem for Linux (WSL)? Running the command 'npm audit' results in an error message, "failed, reason: socker hang up".
Starting with a fresh Ubuntu 18.04 LTS installation under Windows 10 WSL2, I can log in and reproduce the error with the following commands:
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
- bash
- nvm install --lts
- npx express-generator HelloWorld --view=pug
- cd HelloWorld
- npm install
- npm audit
Resulting error:
npm ERR! code ECONNRESET npm ERR! errno ECONNRESET npm ERR! network request to https://registry.npmjs.org/-/npm/v1/security/audits failed, reason: socket hang up
Things I have done to troubleshoot the problem:
- I get valid responses from the npmjs registry URL specified in the error using curl and wget
- 'npm audit' works under Windows 10 with Node JS v14.15.1
- The error also occurs using Debian under WSL2
- The error occurs using different versions (nvm version 0.37.2, node v14.15.1, node v15.3.0, npm v6.14.8, and npm v7.0.14)
- The error occurs regardless of whether the Windows Firewall is on or off
- Clearing the npm cache didn't change anything
- npm is not configured to use a proxy server
- Using HTTP instead of HTTPS for the npm registry url did not fix the problem
Any ideas on further troubleshooting steps or possible fixes? I've Googled and tried every possible solution with no luck so far.
Thank you in advance!