Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Fails to unpack the source package with scoped package #46

Open
jnv opened this issue Oct 17, 2021 · 2 comments · May be fixed by #47
Open

Fails to unpack the source package with scoped package #46

jnv opened this issue Oct 17, 2021 · 2 comments · May be fixed by #47

Comments

@jnv
Copy link

jnv commented Oct 17, 2021

Node 16.9.1, npm 7.20.3

I am trying to run npm test for scoped package @atom/watcher I would like to add. However, I am getting the following error:

tar (child): @atom/watcher-1.3.5.tgz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Upon further inspection, it looks like npm pack doesn't return a correct filename in the JSON:

$ npm pack @atom/watcher --json
[
  {
    "id": "@atom/watcher@1.3.5",
    "name": "@atom/watcher",
    "version": "1.3.5",
    "size": 109100,
    "unpackedSize": 449712,
    "shasum": "30efe6ecb8cf0985116f25765ce467b41bca3d6b",
    "integrity": "sha512-QP95EnVtpQmlNVL3ravmVBbTDFteRi99CGvlP925d0+WvjPHSPOKYLxDUP3WyT+fCKqW0sboKrpPSwnbMZvCJw==",
    "filename": "@atom/watcher-1.3.5.tgz",
    "files": [
    ... removed

Notice that filename property states "@atom/watcher-1.3.5.tgz", however, the fetched file has name atom-watcher-1.3.5.tgz.

I was able to fix this by modifying the filename extracted from JSON here:

const tarballName = npmPack.endsWith(".tgz") ? npmPack : JSON.parse(npmPack)[0].filename as string;

to

const tarballName = npmPack.endsWith(".tgz") ? npmPack : JSON.parse(npmPack)[0].filename.replace('/', '-').replace('@', '') as string;

Of course, this isn't pretty but does the job. Also I am not sure whether this works with older versions of npm, notably npm 6.

Alternatively perhaps this should be fixed in npm?

@noahtallen
Copy link

Related issues

@noahtallen noahtallen linked a pull request Nov 12, 2021 that will close this issue
@noahtallen
Copy link

A workaround is to use an older npm version, such as v6.14.15.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants