Lately I am hooked to WSL and have been using bash as my main terminal. It has auto complete, allows me to connect to my Raspberry PI and it just feels nice. However, I recently hit an issue where in I was not able to run any
npm commands in
zsh shell. Every time I ran any
npm command I received error saying
getaddrinfo EAI_AGAIN registry.npmjs.org. In this short post, I would like to show how I solved it.
I get EAI_AGAIN error when I run npm commands from zsh on #WSL but works fine on cmd in Windows Terminal. What am I missing? doesn't seem to be a proxy issue - Any help appreciated! #npm #wsl #node #error pic.twitter.com/elig0XigvP— Utkarsh Shigihalli (@onlyutkarsh) May 4, 2020
Quick Google search and it was apparent that
bash shell was not able to connect to the Internet. Scanning through the results, I found a link to WSL documentation and some common issues list.
Although none were actually resolutions to fix the specific error I was having, I decided to check my DNS setting for the
zsh. So I ran
cat command and to my surprise DNS entries were not right. Especially it was interesting to see that this (
resolv.conf) file is autogenerated, so not sure if it was changed when I switched from
> cat /etc/resolv.conf # This file was automatically generated by WSL.. nameserver xxx.xxx.xxx.xxx
I altered the file (after taking backup) with correct DNS entries.
> sudo nano /etc/resolv.conf
Save and restarted the WSL, and boom! the
npm command was working!
That is it, a quick post on how I solved the
EAI_AGAIN error in WSL and a reminder to myself that I should check
resolv.conf before blaming
oh-my-zsh or the WSL 🙏🏼.