node.jsnpm

npm install always ETIMEOUT can's fix


I have spent my whole day on fixing this problem but can't see any light.

My node and npm version is below

Information of node and npm

And no matter what package I wanna install, it always show enter image description here

enter image description here

enter image description here

I am sure that I am not in any proxy and I have already lower my node version from 18 to 14, but the problem still exist!!!!

Could anyone know how to fix this problem help me? I already tried every way to fix this but can't work.


Solution

  • Since when did the issue start? Did it occur after you installed any dependency or made any proxy / firewall related configurations?

    However you can try one of the following ways to fix this issue

    1. Delete node_modules folder and in terminal, write
    npm install
    
    1. Change your nodejs version, either upgrade it or downgrade it

    2. Reinstall nodejs

    3. Try some other package manager like yarn

    Note: When changing your nodejs version, please ensure that your node version is compitable with the npm version

    Edit: If these solutions don't work, the error is most probably caused by network related issues, you can try the following fixes

    1. In terminal, reset the registry path of your node package manager
    npm config set registry http://registry.npmjs.org/
    
    1. If you are using your organization's computer, you need to use a proxy, remember to change the proxy url and port as per your organization
    npm config set proxy http://proxyurl.com:8080
    npm config set https-proxy http://proxyurl.com:8080
    
    1. Instead of local installation, try installing packages globally i.e
    npm install -g mongoose
    
    1. Clear the cache
    npm cache verify
    
    1. Switch your device to some other wifi network and then try installing some npm packages