Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm pack incorrect filename for scoped package #3405

Closed
1 task done
breavyn opened this issue Jun 12, 2021 · 5 comments · Fixed by #5894
Closed
1 task done

[BUG] npm pack incorrect filename for scoped package #3405

breavyn opened this issue Jun 12, 2021 · 5 comments · Fixed by #5894
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@breavyn
Copy link

breavyn commented Jun 12, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

npm pack and npm pack --json show the incorrect filename when packing a package with a scoped name.

% npm pack
npm notice
npm notice 📦  @my-scope/my-package@1.0.0
npm notice === Tarball Contents ===
npm notice 0B   index.js
npm notice 276B my-scope-my-package-1.0.0.tgz
npm notice 234B package.json
npm notice === Tarball Details ===
npm notice name:          @my-scope/my-package
npm notice version:       1.0.0
npm notice filename:      @my-scope/my-package-1.0.0.tgz
npm notice package size:  611 B
npm notice unpacked size: 510 B
npm notice shasum:        ab0b16e335388b69eec923e62d66d7f1eaf33cb7
npm notice integrity:     sha512-/PBmytzQRHwxf[...]FpBf4pRsXjy4w==
npm notice total files:   3
npm notice
my-scope-my-package-1.0.0.tgz

Notice npm notice filename: @my-scope/my-package-1.0.0.tgz is not the correct filename.

% npm pack --json
[
  {
    "id": "@my-scope/my-package@1.0.0",
    "name": "@my-scope/my-package",
    "version": "1.0.0",
    "size": 276,
    "unpackedSize": 234,
    "shasum": "2ce6365bb4ea5e1fc04b9bc24815b479024f392d",
    "integrity": "sha512-ZzUDBQ6QDe1X/+7hXofN3BLvbzFD7EPiuxzwAU7MsJiHQRpk3nod8ezGCo4CCNekQvGXF7wQwQnPkCddCUyimQ==",
    "filename": "@my-scope/my-package-1.0.0.tgz",
    "files": [
      {
        "path": "index.js",
        "size": 0,
        "mode": 420
      },
      {
        "path": "package.json",
        "size": 234,
        "mode": 420
      }
    ],
    "entryCount": 2,
    "bundled": []
  }
]

Expected Behavior

The correct filename to be displayed, in the above example my-scope-my-package-1.0.0.tgz.

Steps To Reproduce

  1. In a project with a scoped package e.g @my-scope/my-package
  2. Run npm pack or npm pack --json

Environment

  • OS: Gentoo Linux
  • Node: 16.3.0
  • npm: 7.15.1 (also tested on latest HEAD)
@breavyn breavyn added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Jun 12, 2021
@breavyn
Copy link
Author

breavyn commented Jun 12, 2021

Perhaps it is just a matter of adding the string replacement, .replace(/^@/, '').replace(/\//, '-'), here.

filename: `${manifest.name}-${manifest.version}.tgz`,

Instead of at individual sites like here.

cli/lib/pack.js

Lines 83 to 86 in 3f202cd

for (const tar of tarballs) {
logTar(tar, { log, unicode })
this.npm.output(tar.filename.replace(/^@/, '').replace(/\//, '-'))
}

@noahtallen
Copy link

Verifying this is still an issue on npm v8.1.3:

$ ls

$ npm pack "@wordpress/data-controls"
npm notice
npm notice 📦  @wordpress/data-controls@2.2.6
...
npm notice filename:      @wordpress/data-controls-2.2.6.tgz
...
wordpress-data-controls-2.2.6.tgz

$ ls
wordpress-data-controls-2.2.6.tgz

@noahtallen
Copy link

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

@phated
Copy link
Contributor

phated commented May 31, 2022

Just encountered this same issue in some workflows.

@fredxie
Copy link

fredxie commented Jul 13, 2022

Is there any update on this?
Experiencing the same issue here. scoped prefix (@xxx) transformed to incorrect tarball name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants