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

Fails to unpack the source package with scoped package #46

@jnv

Description

@jnv

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/[email protected]",
    "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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions