[Resolved] Workaround for resolving npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format

[Resolved] Workaround for resolving npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format

Overview

Recently, users have encountered issues in their Node.js builds, reporting errors such as:
  • npm WARN tar TAR_BAD_ARCHIVE: Unrecognized archive format
  • Request failed "304 Not Modified" (if using Yarn as the package manager).

This issue has primarily been reported in the Asia region and appears to stem from the NPM registry. You can track the ongoing discussion and updates regarding this issue on the NPM CLI GitHub issue thread.

Temporary Workaround

To bypass this issue temporarily, you can leverage a public NPM registry mirror maintained by the Chinese developer community, CNPM.

Important Notes

  • This workaround works only if your application does not rely on private dependencies.
  • This workaround is provided as a temporary measure. We recommend switching back to the official NPM registry once the issue is resolved to ensure optimal security and reliability.

Implementation Steps

1. Using a Dockerfile

If you are using a Dockerfile in your project, add the following command before copying your package.json file:

RUN npm config set registry https://registry.npmmirror.com/

2. Using an .npmrc File

If you are configuring via .npmrc, add this line to your .npmrc file:

registry=https://registry.npmmirror.com/

Please be aware, Devtron neither owns nor is affiliated with this npm mirror, however this npm mirror is widely used by Developers across China.

Updates


Dec 17, 2024 - 12:50 UTC:   NPM team has acknowledged the issue and they'll be fixing it soon, You can track it at https://status.npmjs.org/

    • Related Articles

    • Resolving DNS resolution issues with Coredns

      Problem statement Increase in timeouts while DNS resolution in a Kubernetes Cluster (EKS on AWS). Suspected Problem Coredns getting overwhelmed with DNS resolution requests and resolution takes multiple hops and searches thus decreasing Coredns ...
    • Devtron Enterprise DT-33 Release Note

      The latest release of Devtron is here, with new features and enhancements. Here's a summary of the DT-33 release and related updates. Highlights: Exception in Configuration Approval Policies (Beta) When urgent releases are needed, teams often face ...
    • Devtron Enterprise DT-32 Release Note

      The latest release of Devtron is here, with new features and enhancements. Here's a summary of the DT-32 release and related updates. Highlights: Application Templates Devtron is introducing Application Templates, a feature that allows users to ...