Why Some npm Packages Return 404 Error Messages

Andrey Granovsky
2023-01-22 11:07

Relevant versions: This information pertains toArtifactory versions 5.5.2 and above.

Withallremote repositories and regardless of package type, before sending aGET requestto resolve a package from a remote endpoint, Artifactory sends aHEAD requestto that endpoint. Upon receiving a200code response for the HEAD request, the GET request is sent.

However, when working with thenpm public registry, HEAD requests will sometimes trigger a404 errorresponse even though the requested package exists. As a result, Artifactory won’t send a GET request to resolve the package and the entire request will fail. This will occur when a package hasn’t been installed successfully.

As aworkaround, do the following:

  1. In yournpm-remote repository, under theAdvancedtab, enableBypass HEAD Requests, which will eliminate the sending ofnpm public registryHEAD requests.
  2. Thereafter, from theUI, click onArtifacts, right click on thename你的npm cache repository, and then selectZap Cache.