[BUG] npm error TAR_BAD_ARCHIVE: Unrecognized archive format
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
When ever I trying to install pm2 (some other packages also having this issue) globally using npm i -g pm2 it is showing me this error
npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm error code TAR_BAD_ARCHIVE
npm error TAR_BAD_ARCHIVE: Unrecognized archive format
npm error A complete log of this run can be found in: /home/omirror/.npm/_logs/2024-12-16T22_49_04_414Z-debug-0.log
I tried this with yarn, pnpm also. Same issues facing using yarn or pnpm. I tried this with Ubuntu 22.04, Ubuntu 24.04, Fedora Cloud 41 Besides I also tried this with node-lts 18, 20, 22 and with latest npm.
Expected Behavior
No response
Steps To Reproduce
- In this environment...
- With this config...
- Run '...'
- See error...
Environment
- npm: 10.9.0, 11.0.0
- Node.js: LTS 18, 20 & 22
- OS Name: Ubuntu 22.04, Ubuntu 24.04, Fedora Cloud 41
- System Model Name: VPS
- npm config:
; node bin location = /home/omirror/.nvm/versions/node/v22.12.0/bin/node
; node version = v22.12.0
; npm local prefix = /home/omirror
; npm version = 10.9.0
; cwd = /home/omirror
; HOME = /home/omirror
; Run `npm config ls -l` to show all defaults.
I am also facing this issue, is there any resolution for this?
NPM registry seems to be returning 304 for packages
to reproduce it locally, you need to clear npm cache and try again
rm -rf node_modules/ && npm cache clean --force && npm i
as this is from the registry, it is happening on other package managers as well
It appears to be a region-specific issue, currently only reproducible in India
https://github.com/npm/cli/issues/3229 seems to be related
Does it mean, migrating from npm to yarn is the solution?
Any other mitigation?
Our production systems are down because of this.
Yes it is region specific issue. Our ci/cd are failing on Mumbai region.
Any workaround on this? Even we are facing issue on our production systems build.
We have tried everything. Like Clearing the cache. Restarted self host runner. But no luck. Same error everytime. Npm team should look into this asap
Yup failing for me as well, in local. Surprisingly this works on the github actions CI/CD pipeline.
Any work around found for this ?
we tried
- Clearing cache
- Upgrading and downgrading the node versions
- Changing package manager to yarn.
Nothing working on the azure CI/CD, but works on the local.
@abhijith-tp-zora
This might be why yarn isn't working.
Our production AWS beanstalk deployment is out of service because of this since 12 hours already-
2024/12/17 06:00:55.969865 [INFO] The dir .platform/hooks/prebuild/ does not exist
2024/12/17 06:00:55.969866 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/prebuild
2024/12/17 06:00:55.969868 [INFO] Executing instruction: Install customer specified node.js version
2024/12/17 06:00:55.969972 [WARN] using default version of nodejs instead of installing specified version of nodejs
2024/12/17 06:00:55.969975 [INFO] Executing instruction: Use NPM to install dependencies
2024/12/17 06:00:55.969980 [INFO] use npm to install dependencies
2024/12/17 06:00:55.969996 [INFO] Getting npm verison
2024/12/17 06:00:55.970001 [INFO] Running command: npm --version
2024/12/17 06:00:57.161813 [INFO] 10.7.0
2024/12/17 06:00:57.161845 [INFO] Using npm v10
2024/12/17 06:00:57.161863 [INFO] Running command: /bin/su webapp -c npm --omit=dev install
2024/12/17 06:03:16.449305 [INFO] npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format
npm warn deprecated [email protected]: Package is no longer maintained
npm warn deprecated [email protected]: < 22.8.2 is no longer supported
npm warn deprecated [email protected]: Package is no longer maintained
npm warn deprecated [email protected]: Package is no longer maintained
npm notice
npm notice New major version of npm available! 10.7.0 -> 11.0.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.0.0
npm notice To update run: npm install -g [email protected]
npm notice
npm error code TAR_BAD_ARCHIVE
npm error TAR_BAD_ARCHIVE: Unrecognized archive format
npm error A complete log of this run can be found in: /home/webapp/.npm/_logs/2024-12-17T06_00_57_487Z-debug-0.log
2024/12/17 06:03:16.449359 [ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/su webapp -c npm --omit=dev install failed with error exit status 1. Stderr:npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format
npm warn deprecated [email protected]: Package is no longer maintained
npm warn deprecated [email protected]: < 22.8.2 is no longer supported
npm warn deprecated [email protected]: Package is no longer maintained
npm warn deprecated [email protected]: Package is no longer maintained
npm notice
npm notice New major version of npm available! 10.7.0 -> 11.0.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.0.0
npm notice To update run: npm install -g [email protected]
npm notice
npm error code TAR_BAD_ARCHIVE
npm error TAR_BAD_ARCHIVE: Unrecognized archive format
npm error A complete log of this run can be found in: /home/webapp/.npm/_logs/2024-12-17T06_00_57_487Z-debug-0.log
@abhijith-tp-zora
This might be why yarn isn't working.
That was it. We tried switching the registry with yarn config set registry https://registry.npmmirror.com/ and it worked for us in production.
For npm users, setting npm config set registry https://registry.npmmirror.com/ worked locally. For production, we had to append registry=https://registry.npmmirror.com/ in the .npmrc.
curl -I https://registry.npmjs.org/
HTTP/2 200
date: Tue, 17 Dec 2024 06:50:13 GMT
content-type: application/json
cf-ray: 8f34fa4668b14166-BOM
cf-cache-status: DYNAMIC
npm-notice: This endpoint is deprecated. Use https://replicate.npmjs.com instead.
server: cloudflare
The notice says to use replicate endpoint. Not sure what to do in this case
My CodeBuild execution gives me the "npm ERR! code EINTEGRITY" error.
[Container] 2024/12/17 07:03:47.294476 Running command npm install pm2 -g
44 | npm ERR! code EINTEGRITY 45 | npm ERR! sha512-5EM1GHXycJBS6mauYAbVKT1cVs7POKWb2NXD4Vyt8dDqeZa7LaDK1/sjtL+Zb0lzTpSNil4596Dyu97hz37QLg== integrity checksum failed when using sha512: wanted sha512-5EM1GHXycJBS6mauYAbVKT1cVs7POKWb2NXD4Vyt8dDqeZa7LaDK1/sjtL+Zb0lzTpSNil4596Dyu97hz37QLg== but got sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg==. (0 bytes) 46 | 47 | npm ERR! A complete log of this run can be found in: 48 | npm ERR! /root/.npm/_logs/2024-12-17T07_03_49_452Z-debug.log 49 | 50 | [Container] 2024/12/17 07:03:49.467940 Command did not exit successfully npm install pm2 -g exit status 1 51 | [Container] 2024/12/17 07:03:49.473916 Phase complete: BUILD State: FAILED 52 | [Container] 2024/12/17 07:03:49.473934 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install pm2 -g. Reason: exit status 1
Any workaround yet?
For npm users, setting
npm config set registry https://registry.npmmirror.com/worked locally. For production, we had to appendregistry=https://registry.npmmirror.com/in the.npmrc.
: )
@sagrawal31
I have created a file .nmprc contains registry=https://registry.npmmirror.com/, added copy command to the Dockerfile
**COPY .npmrc /root/.npmrc** but still not working for me . can you suggest some other way.
@sagrawal31 I have created a file .nmprc contains registry=https://registry.npmmirror.com/, added copy command to the Dockerfile
**COPY .npmrc /root/.npmrc**but still not working for me . can you suggest some other way.
Add this line in your Dockerfile before the npm install. No need to create .npmrc file unless you're using a private registry.
RUN npm config set registry https://registry.npmmirror.com/ --global
@crup working for me now thank you.
@stssathishr, the suggestion given by @crup should also work as it will set the same registry in the docker's image (usually at ~/.npmrc).
How safe is it to use https://registry.npmmirror.com/? 🤔 Also has been able to conclude which region is this specific to?
This might be why yarn isn't working.