Timeout errors in the NPM are commonly caused by the amount of dependency associated with a specific package. This issue is particularly prevalent in NPM versions 6.14.4 and older, as the default timeout period was set to only one minute. However, newer versions of NPM have extended the default timeout to five minutes. In this article, we'll explore how to resolve these timeout issues and get your NPM installs running smoothly.
Increase the timeout
1. Adjust the timeout value in your NPM configuration file, .npmrc. Here's how: (for Older NPM Versions)
- Open your .npmrc file, Add the following line to adjust the timeout value:
timeout=<timeout_in_milliseconds>Replacing <timeout_in_milliseconds> with the desired timeout in milliseconds. For instance, if you want to set the timeout to 5 minutes, you should use: timeout=300000
This modification allows you to customize the timeout according to your needs, even with older NPM versions.
2. Upgrade NPM, Client.
- Upgrade your NPM client to a version greater than 6.14.4. By doing so, you will automatically benefit from the increased default timeout of 5 minutes.
- When using a virtual remote repository alongside your remote repository, enabling the 'external dependencies rewrite' option can effectively address timeout issues related to npm packages. It's important to be aware that during the initial download of these packages, this may result in longer download times. However, this option empowers Artifactory to cache the external dependencies and serve the content locally, ultimately decreasing the chances of encountering timeouts.
Please note: for example the packages Axe-core have many dependencies and could cause a timeout.