0
votes

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:

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!

1
After further troubleshooting, the error occurs on WSL2, but not on WSL1. I can toggle the version of WSL associated with the Ubuntu/Debian installation to reproduce the problem or make it go away. I tried removing/reinstalling WSL2 with no luck. One thing I noticed is that the computer with the problem is on Windows 10 Pro build 18363. The computers not having the problems are on build 19042.Lazor

1 Answers

0
votes

In case this helps someone else... WSL2 has a minimum build requirement of Windows 10 version 1909 (build 10.0.18363), but the command "npm audit" did not work on this version. Upgrading Windows 10 to version 2004 resolved the problem.