TAR_BAD_ARCHIVE and TAR_ENTRY_INVALID when trying to npm install any package
Asked Answered
F

5

10

I tried to delete npm_cache and install the latest version of npm, but it didn't work. I have no additional ideas because I searched all the similar questions with the same error. I can't even npm install, though global installations work. This error is only present within this project. Installations in other projects on my machine work as usual.

npm install axios
npm WARN tar TAR_ENTRY_INVALID checksum failure
npm WARN tar TAR_ENTRY_INVALID checksum failure
npm WARN tar TAR_ENTRY_INVALID checksum failure
npm WARN tar TAR_ENTRY_INVALID checksum failure
npm WARN tar TAR_BAD_ARCHIVE: Unrecognized archive format
npm ERR! code TAR_BAD_ARCHIVE
npm ERR! TAR_BAD_ARCHIVE: Unrecognized archive format

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Local\npm-cache\_logs\2021-02-14T22_59_28_705Z-debug.log

Here is what it logs when I try npm install axios -verbose.

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'install',
0 verbose cli   'axios'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 3ms
4 timing config:load:file:C:\Users\User\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 3ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:C:\Users\User\Desktop\ecommerce\ecommerce\.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\User\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Program Files\nodejs\etc\npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 2ms
18 timing config:load Completed in 13ms
19 verbose npm-session 2948ad5d93d129dc
20 timing npm:load Completed in 33ms
21 timing arborist:ctor Completed in 2ms
22 timing idealTree:init Completed in 1806ms
23 timing idealTree:userRequests Completed in 9ms
24 silly idealTree buildDeps
25 silly fetch manifest homepage@https://xyz.github.io/ecommerce
26 warn tar TAR_ENTRY_INVALID checksum failure
27 silly tar TAR_ENTRY_INVALID checksum failure {
27 silly tar   header: Header {
27 silly tar     cksumValid: false,
27 silly tar     needPax: false,
27 silly tar     nullBlock: false,
27 silly tar     block: null,
27 silly tar     path: '<!DOCTYPE html>\n' +
27 silly tar       '<html lang="en">\n' +
27 silly tar       '  <head>\n' +
27 silly tar       '    <meta charset="utf-8" />\n' +
27 silly tar       '    <meta name="viewport" con',
27 silly tar     mode: null,
27 silly tar     uid: null,
27 silly tar     gid: null,
27 silly tar     size: null,
27 silly tar     mtime: null,
27 silly tar     cksum: null,
27 silly tar     linkpath: '     name="description"\n' +
27 silly tar       '      content="Web site created using create-react-app"\n' +
27 silly tar       '    />\n' +
27 silly tar       '    <link\n' +
27 silly tar       '   ',
27 silly tar     uname: null,
27 silly tar     gname: null,
27 silly tar     devmaj: 0,
27 silly tar     devmin: 0,
27 silly tar     atime: null,
27 silly tar     ctime: null,
27 silly tar     [Symbol(type)]: ' '
27 silly tar   },
27 silly tar   cwd: 'C:\\Users\\User\\AppData\\Local\\npm-cache\\_cacache\\tmp\\b7842840',
27 silly tar   code: 'TAR_ENTRY_INVALID',
27 silly tar   tarCode: 'TAR_ENTRY_INVALID'
27 silly tar }
28 warn tar TAR_ENTRY_INVALID checksum failure
29 silly tar TAR_ENTRY_INVALID checksum failure {
29 silly tar   header: Header {
29 silly tar     cksumValid: false,
29 silly tar     needPax: false,
29 silly tar     nullBlock: false,
29 silly tar     block: null,
29 silly tar     path: ' type="image/png"\n' +
29 silly tar       '      sizes="16x16"\n' +
29 silly tar       '      href="%PUBLIC_URL%/favicon-16x16.png"\n' +
29 silly tar       '    />\n' +
29 silly tar       '    <link r',
29 silly tar     mode: null,
29 silly tar     uid: null,
29 silly tar     gid: null,
29 silly tar     size: null,
29 silly tar     mtime: null,
29 silly tar     cksum: null,
29 silly tar     linkpath: 'mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />\n' +
29 silly tar       '    <meta name="msapplication-TileColor"',
29 silly tar     uname: null,
29 silly tar     gname: null,
29 silly tar     devmaj: 0,
29 silly tar     devmin: 0,
29 silly tar     atime: null,
29 silly tar     ctime: null,
29 silly tar     [Symbol(type)]: '"'
29 silly tar   },
29 silly tar   cwd: 'C:\\Users\\User\\AppData\\Local\\npm-cache\\_cacache\\tmp\\b7842840',
29 silly tar   code: 'TAR_ENTRY_INVALID',
29 silly tar   tarCode: 'TAR_ENTRY_INVALID'
29 silly tar }
30 warn tar TAR_ENTRY_INVALID checksum failure
31 silly tar TAR_ENTRY_INVALID checksum failure {
31 silly tar   header: Header {
31 silly tar     cksumValid: false,
31 silly tar     needPax: false,
31 silly tar     nullBlock: false,
31 silly tar     block: null,
31 silly tar     path: 'pp-manifest/\n' +
31 silly tar       '    -->\n' +
31 silly tar       '    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />\n' +
31 silly tar       '    <!--\n' +
31 silly tar       '      No',
31 silly tar     mode: null,
31 silly tar     uid: null,
31 silly tar     gid: null,
31 silly tar     size: null,
31 silly tar     mtime: null,
31 silly tar     cksum: null,
31 silly tar     linkpath: 'will be replaced with the URL of the `public` folder during the build.\n' +
31 silly tar       '      Only files inside the `',
31 silly tar     uname: null,
31 silly tar     gname: null,
31 silly tar     devmaj: 0,
31 silly tar     devmin: 0,
31 silly tar     atime: null,
31 silly tar     ctime: null,
31 silly tar     [Symbol(type)]: ' '
31 silly tar   },
31 silly tar   cwd: 'C:\\Users\\User\\AppData\\Local\\npm-cache\\_cacache\\tmp\\b7842840',
31 silly tar   code: 'TAR_ENTRY_INVALID',
31 silly tar   tarCode: 'TAR_ENTRY_INVALID'
31 silly tar }
32 warn tar TAR_ENTRY_INVALID checksum failure
33 silly tar TAR_ENTRY_INVALID checksum failure {
33 silly tar   header: Header {
33 silly tar     cksumValid: false,
33 silly tar     needPax: false,
33 silly tar     nullBlock: false,
33 silly tar     block: null,
33 silly tar     path: ' by running `npm run build`.\n' +
33 silly tar       '    -->\n' +
33 silly tar       '    <link\n' +
33 silly tar       '      rel="stylesheet"\n' +
33 silly tar       '      href="https://maxcdn.boo',
33 silly tar     mode: null,
33 silly tar     uid: null,
33 silly tar     gid: null,
33 silly tar     size: 4,
33 silly tar     mtime: null,
33 silly tar     cksum: null,
33 silly tar     linkpath: '  integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"\n' +
33 silly tar       '      crossori',
33 silly tar     uname: null,
33 silly tar     gname: null,
33 silly tar     devmaj: 0,
33 silly tar     devmin: 0,
33 silly tar     atime: null,
33 silly tar     ctime: null,
33 silly tar     [Symbol(type)]: ' '
33 silly tar   },
33 silly tar   cwd: 'C:\\Users\\User\\AppData\\Local\\npm-cache\\_cacache\\tmp\\b7842840',
33 silly tar   code: 'TAR_ENTRY_INVALID',
33 silly tar   tarCode: 'TAR_ENTRY_INVALID'
33 silly tar }
34 warn tar TAR_BAD_ARCHIVE: Unrecognized archive format
35 silly tar Error: TAR_BAD_ARCHIVE: Unrecognized archive format
35 silly tar     at Unpack.warn (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\warn-mixin.js:19:40)
35 silly tar     at Unpack.warn (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\unpack.js:189:18)
35 silly tar     at Unpack.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:81:14)
35 silly tar     at Unpack.emit (node:events:339:22)
35 silly tar     at Unpack.[emit] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:285:12)
35 silly tar     at Unpack.[maybeEnd] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:401:17)
35 silly tar     at Unpack.[consumeChunk] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:432:21)
35 silly tar     at Unpack.write (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:364:25)
35 silly tar     at Unpack.end (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:477:14)
35 silly tar     at Yallist.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\minipass\index.js:396:18)
35 silly tar  Error: TAR_BAD_ARCHIVE: Unrecognized archive format
35 silly tar     at Unpack.warn (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\warn-mixin.js:19:40)
35 silly tar     at Unpack.warn (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\unpack.js:189:18)
35 silly tar     at Unpack.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:81:14)
35 silly tar     at Unpack.emit (node:events:339:22)
35 silly tar     at Unpack.[emit] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:285:12)
35 silly tar     at Unpack.[maybeEnd] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:401:17)
35 silly tar     at Unpack.[consumeChunk] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:432:21)
35 silly tar     at Unpack.write (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:364:25)
35 silly tar     at Unpack.end (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:477:14)
35 silly tar     at Yallist.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\minipass\index.js:396:18) {
35 silly tar   recoverable: false,
35 silly tar   cwd: 'C:\\Users\\User\\AppData\\Local\\npm-cache\\_cacache\\tmp\\b7842840',
35 silly tar   code: 'TAR_BAD_ARCHIVE',
35 silly tar   tarCode: 'TAR_BAD_ARCHIVE'
35 silly tar }
36 http fetch GET 200 https://xyz.github.io/ecommerce/ 2815ms
37 silly fetch manifest axios@*
38 http fetch GET 200 https://registry.npmjs.org/axios 178ms
39 silly placeDep ROOT [email protected] OK for: [email protected] want: *
40 silly placeDep ROOT homepage@ OK for: [email protected] want: https://xyz.github.io/ecommerce
41 timing idealTree:#root Completed in 3124ms
42 timing idealTree:node_modules/axios Completed in 0ms
43 timing idealTree:node_modules/homepage Completed in 0ms
44 timing idealTree:buildDeps Completed in 3127ms
45 timing idealTree:fixDepFlags Completed in 23ms
46 timing idealTree Completed in 4968ms
47 timing command:install Completed in 5002ms
48 verbose stack Error: TAR_BAD_ARCHIVE: Unrecognized archive format
48 verbose stack     at Unpack.warn (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\warn-mixin.js:19:40)
48 verbose stack     at Unpack.warn (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\unpack.js:189:18)
48 verbose stack     at Unpack.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:81:14)
48 verbose stack     at Unpack.emit (node:events:339:22)
48 verbose stack     at Unpack.[emit] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:285:12)
48 verbose stack     at Unpack.[maybeEnd] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:401:17)
48 verbose stack     at Unpack.[consumeChunk] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:432:21)
48 verbose stack     at Unpack.write (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:364:25)
48 verbose stack     at Unpack.end (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:477:14)
48 verbose stack     at Yallist.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\minipass\index.js:396:18)
49 verbose cwd C:\Users\User\Desktop\ecommerce\ecommerce
50 verbose Windows_NT 10.0.19041
51 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "axios"
52 verbose node v15.0.0
53 verbose npm  v7.5.4
54 error code TAR_BAD_ARCHIVE
55 error TAR_BAD_ARCHIVE: Unrecognized archive format
56 verbose exit 1

Fitzger answered 14/2, 2021 at 23:2 Comment(6)
Does this error occur if you do a fresh clone of the project? Have you tried removing and reinstalling node_modules in the project? Have you tried npm cache verify and/or npm cache clean --force? Does this occur with any package or just axios?Decorator
I tried cleaning cache, also now I deleted node_modules and this error occurs when I hit npm install so now I can't even install node_modulesFitzger
What's in the debug log? Is it the same as the --verbose output?Decorator
Have you tried npm doctor?Decorator
I reinstalled whole node and this error is no more there, Now I have error while deploying react appFitzger
In my case it was caused by yarn - my project is managed by yarn, not npm. Npm emits this type of errors, when it used instead of yarn.Meares
F
1

In the end, I tried to reinstall Node and error was gone. Also try cleaning cache before it.

Fitzger answered 10/1, 2022 at 9:10 Comment(1)
my npm install doesn't work after I reinstall the Node and clean the cache. It shows below:npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar TAR_BAD_ARCHIVE: Unrecognized archive format npm ERR! code TAR_BAD_ARCHIVE npm ERR! TAR_BAD_ARCHIVE: Unrecognized archive format No idea what to do now. Can Someone help?Reynoso
C
2

when I remove the homepage from the package.json it workes fine.

Chatterton answered 5/4, 2023 at 7:46 Comment(1)
This worked for me, after also removing the proxy from package.jsonPrytaneum
F
1

In the end, I tried to reinstall Node and error was gone. Also try cleaning cache before it.

Fitzger answered 10/1, 2022 at 9:10 Comment(1)
my npm install doesn't work after I reinstall the Node and clean the cache. It shows below:npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar TAR_BAD_ARCHIVE: Unrecognized archive format npm ERR! code TAR_BAD_ARCHIVE npm ERR! TAR_BAD_ARCHIVE: Unrecognized archive format No idea what to do now. Can Someone help?Reynoso
C
1

Sometimes an unexpected version format or value lands inside a package.json file. Validate if your package.json is correct.

Cloddish answered 2/8, 2022 at 12:31 Comment(0)
H
0

Before I started having this issue, I added a key to my package.json file named homepage and the value is the domain name of my website. I just removed it and everything worked fine. So if you're experiencing similar issue and you've uninstalled and reinstalled node, cleared cached and the issue persists. I'd advise you verify the package.json file

Hypotaxis answered 24/10, 2022 at 14:53 Comment(0)
D
0
  1. clear npm items:

npm config rm proxy

npm config rm https-proxy

npm cache clean -f

  1. delete package-lock.json file

  2. npm install

Detrusion answered 2/7 at 1:32 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Obstruent

© 2022 - 2024 — McMap. All rights reserved.