The solution was found on a Reddit post down in the comments. Apparently, there’s some kind of issue happening in the DNS resolver.
Run the following commands in WSL. Substitute 18.104.22.168 with a DNS resolver of your choice.
sudo rm /etc/resolv.conf sudo bash -c 'echo "nameserver 22.214.171.124" > /etc/resolv.conf' sudo bash -c 'echo "[network]" > /etc/wsl.conf' sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf' sudo chattr +i /etc/resolv.conf
Then run the following command in a prompt with admin privilege
No guarantee this won’t cause other issues down the road, but it solved my NPM install problem.