DEV Community

Cover image for npm install falls into timeout, what can you do?
Mariana Ferreira
Mariana Ferreira

Posted on

npm install falls into timeout, what can you do?

npm install falls into timeout a couple of times and you can't install your packages?

err socket timeout

If your internet is slow and you have many dependencies, try this:

npm install --prefer-offline
Enter fullscreen mode Exit fullscreen mode

npm install checks every package to see if there is a new version available for download.

With --prefer-offline (see documentation), if you already have a package installed in a version that matches your package.json, it will not check for the lastest version to download. Only if there is no version in the npm cache will it request these missing packages from the server.

This is faster because it will check and install only the packages you don't have. And even if npm install times out again, the packages it downloaded in the meantime are now in the cache, so when you run npm install --prefer-offline again, these packages will not be checked. Eventually, you'll install every package you need!

Thank you for reading! If you have other tips about timeouts or installing npm packages faster, please feel free to share them in the comments.

Top comments (0)