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 --json returns incorrect filename for scoped package #5334

Closed
2 tasks done
pleunv opened this issue Aug 22, 2022 · 1 comment
Closed
2 tasks done

[BUG] npm pack --json returns incorrect filename for scoped package #5334

pleunv opened this issue Aug 22, 2022 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@pleunv
Copy link

pleunv commented Aug 22, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When dealing with a scoped package, the file created on disk is of the format scope-package-1.0.0.tgz.
The filename that is reported by npm pack --json is incorrect as it's reported as @scope/package-1.0.0.tgz instead.
The filename reported by npm pack (without --json) is correct.

Expected Behavior

When running npm pack --json the reported filename property should be scope-package-1.0.0.tgz instead of @scope/package-1.0.0.tgz.

Steps To Reproduce

Given a package.json with the following:

{
  "name": "@scope/package",
  "version": "1.0.0",
}

The output of npm pack is the following, which includes the correct filename:

npm notice
npm notice 📦  @scope/package@1.0.0
npm notice === Tarball Contents ===
npm notice 0B  index.js
npm notice 53B package.json
npm notice === Tarball Details ===
npm notice name:          @scope/package
npm notice version:       1.0.0
npm notice filename:      @scope/package-1.0.0.tgz
npm notice package size:  167 B
npm notice unpacked size: 53 B
npm notice shasum:        ad1ef62b3d84c83033c896f0aee03b701c75b1e8
npm notice integrity:     sha512-NNdAGvap0FZo6[...]oW6ok5Rejsmag==
npm notice total files:   2
npm notice
scope-package-1.0.0.tgz

The output of npm pack --json is the following, which includes an incorrect filename property:

[
  {
    "id": "@scope/package@1.0.0",
    "name": "@scope/package",
    "version": "1.0.0",
    "size": 167,
    "unpackedSize": 53,
    "shasum": "ad1ef62b3d84c83033c896f0aee03b701c75b1e8",
    "integrity": "sha512-NNdAGvap0FZo6aufrgCcRTxV3u9JxwmcHS1wmm9zaNfoD4nQnoGzO4JyRkvozpMadxv1pnhhfoW6ok5Rejsmag==",
    "filename": "@scope/package-1.0.0.tgz",
    "files": [
      {
        "path": "index.js",
        "size": 0,
        "mode": 420
      },
      {
        "path": "package.json",
        "size": 53,
        "mode": 420
      }
    ],
    "entryCount": 2,
    "bundled": []
  }
]

Environment

  • npm: 8.18.0
  • Node.js: v16.15.1
  • OS Name: macOS
  • npm config:
; "user" config from /Users/__redacted__/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /Users/__redacted__/.volta/tools/image/node/16.15.1/bin/node
; node version = v16.15.1
; npm local prefix = /Users/__redacted__/Code/cs-apps/packages/app/dist
; npm version = 8.18.0
; cwd = /Users/__redacted__/Code/cs-apps/packages/app/dist
; HOME = /Users/__redacted__
@pleunv pleunv added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 22, 2022
@wraithgar
Copy link
Member

Duplicate of #3405

@wraithgar wraithgar marked this as a duplicate of #3405 Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants