npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.38k stars 3.1k forks source link

[BUG] TAR_BAD_ARCHIVE: Unrecognized archive format #3229

Open jougene opened 3 years ago

jougene commented 3 years ago

Is there an existing issue for this?

Current Behavior

When I try to install package from private gitlab repository via git+https with user and password, I get multiple

TAR_ENTRY_INVALID checksum failure

errors, and at the end of them - TAR_BAD_ARCHIVE: Unrecognized archive format error.

If I enable verbose logging (npm install --ddd), I can see that somewhere in installation process I had been redirected on main gitlab page for Sign In -

npm http fetch GET 200 https://npm:***@gitlab.private_organisation.com/users/sign_in 674ms

I already tried with node 16 and npm version 6.14.13, and this error did not occur

Expected Behavior

My private package, located in gitlab has been installed successefully

Steps To Reproduce

  1. Add some gitlab private repository in your package.json "private-package": "git+https://user:pass@gitlab.privateorg.com/project/package#commithash"
  2. Run npm install
  3. See above error...

Environment

darcyclarke commented 3 years ago

Action: our team needs to repro

goulu commented 3 years ago

same here with a dependency on our corporate azure git server.

git clone "https://username:password@dev.azure.com/path" works but

"dependencies": {
    "Lib": "https://username:password@dev.azure.com/path"

doesn't...

thomasleveil commented 3 years ago

Same here, all npm version from 7.16.0 are affected while 7.15.1 is working fine

cooldroid commented 3 years ago

Is there any update on this issue? @thomasleveil I tried with 7.15.1 and it's not working for me.

devmediaveille commented 2 years ago

@cooldroid I'm still using 7.15.1 without any issue. I'm now afraid to upgrade

towry commented 2 years ago

My temporary solution is change node(v16.9.1, npm:7.21.1) to node(v14).

I have the same issue, used a private gitlab repo as dependencies, works under node(v14) or below, but fails on node(v16.9.1, npm:7.21.1).

some logs ```txt 9937 warn tar TAR_ENTRY_INVALID checksum failure 9938 silly tar TAR_ENTRY_INVALID checksum failure { 9938 silly tar header: Header { 9938 silly tar cksumValid: false, 9938 silly tar needPax: false, 9938 silly tar nullBlock: false, 9938 silly tar block: null, 9938 silly tar path: '\n' + 9938 silly tar '\n' + 9938 silly tar '\n' + 9938 silly tar '\n' + 9938 silly tar '\n' + 9938 silly tar '\n' + 9938 silly tar '<', 9938 silly tar uname: null, 9938 silly tar gname: null, 9938 silly tar devmaj: 0, 9938 silly tar devmin: 0, 9938 silly tar atime: null, 9938 silly tar ctime: null, 9938 silly tar [Symbol(type)]: 'a' 9938 silly tar }, 9938 silly tar cwd: '/Users/towry/workspace/temp-v2/node_modules/ourlib', 9938 silly tar code: 'TAR_ENTRY_INVALID', 9938 silly tar tarCode: 'TAR_ENTRY_INVALID' 9938 silly tar } 9939 warn tar TAR_ENTRY_INVALID checksum failure 9940 silly tar TAR_ENTRY_INVALID checksum failure { 9940 silly tar header: Header { 9940 silly tar cksumValid: false, 9940 silly tar needPax: false, 9940 silly tar nullBlock: false, 9940 silly tar block: null, 9940 silly tar path: 'mage">\n' + 9940 silly tar '\n' + 9940 silly tar '\n' + 9940 silly tar '\n' + 9940 silly tar '
thasmo commented 2 years ago

We're experiencing the same issue (for private GitLab repositories) when switching from Node 12 / npm 6 to Node 16 / npm 8. Weirdly this doesn't happen locally but in our CI environment only.

The log provided by @towry shows exactly what is also happening in our case.

sonjaerock commented 2 years ago

My solution is to add access token.

By error log, TAR_ENTRY_INVALID checksum failure is archive failure by checksum. Usually checksum is used to check security.

You can make your gitlab repo's access token(only read_repository) and npm install git+https://<token-name>:<token>@gitlab.com/Username/RepositoryName

I solved it. Hope everything goes well :) (Maybe yarn solves automatically by using our local key-chain)

lmshaffe commented 2 years ago

So I've been trying to test this and here's what I've found.

I tested with npm v6.14.17 and I have no issues, but as soon as I use v7.0.0 and up, I get the TAR_ENTRY_INVALID checksum failure issue. Adding the gitlab access token did not work.

I also tested by making a public Gitlab repo to rule out auth issues and I'm still not able to install the Gitlab repo. I tried with a public Github repo and it worked without issue.

I know an earlier comment mentioned they have an issue with an Azure repo, but I'm wondering if there's something different about the way it's able to install Github vs Gitlab (potentially others). I don't know enough yet to understand the deep technicals of that, but wanted to share my testing results and see if sparks an idea.

Also, not sure if this is relevant or helps, but I tried with the latest yarn and that works as well, so the issue seems isolated to npm v7 and up.

salvatore-piccione commented 1 year ago

We're experiencing the same issue (for private GitLab repositories) when switching from Node 12 / npm 6 to Node 16 / npm 8. Weirdly this doesn't happen locally but in our CI environment only.

The log provided by @towry shows exactly what is also happening in our case.

Just to point out that this is still happening with NodeJS 16.16.0 and npm 8.11.0. We are force to migrate to yarn.