I am new to React JS , When I tried to create new React Project or tried to do npm install for react js application , I got ENOTFOUND error :
when I tried to create react js project using command :
npx create-react-app my-app
and when i tried to install packages using command :
npm install
I got ENOTFOUND error as below :
here I will explain how I resolved ENOTFOUND getaddrinfo Error :
ERROR : while creating react js app(npx create-react-app my-app) or while execution npm install command in company environment , we get below error because of proxy server :
NOTE : please get information of proxy server domain and port of your company from your lead or network team : you will get proxy domain and port url like http://proxy-domain.com:8080 and you may get username and password too , we need to use all these 3.
Error Displayed As:
npm ERR! code ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! ..\_logs\2023-10-03T11_09_16_573Z-debug-0.log
Solution for ENOTFOUND getaddrinfo ERROR :
Scenario 1 :
If you have username and authentication code for proxy then use execute below command:
npm config set proxy http://userName:passwordOrAuthenticatioCode@proxy-domain.com:port
npm config set https-proxy http://userName:passwordOrAuthenticatioCode@proxy-domain.com:port
npm config set strict-ssl false
OR
Scenario 2 :
If you dont have username and authentication code for proxy then execute below command:
npm config set proxy http://proxy-domain.com:port
npm config set https-proxy http://proxy-domain.com:port
npm config set strict-ssl false
NOTE :
we executed npm config set strict-ssl false command, to resolve error :
UNABLE_TO_GET_ISSUER_CERT_LOCALLY
request to https://registry.npmjs.org/create-react-app failed,
reason : unable to get local issuer certificate.
now try to create react app using command :
npx create-react-app my-app ,
IT SHOULD WORK SUCCESFULLY
In My case above solution worked perfectly to resolve ENOFOUND error , if you still face issue please comment here , I will give my best to help you…
Happy Learning..