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 in 10.5.0 introduces breaking change due to changed output #7561

Closed
2 tasks done
falsyvalues opened this issue May 27, 2024 · 4 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@falsyvalues
Copy link

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

Prior to v10.5.0 there was possibility to directly redirect npm pack output to file and retrieve tarball file name for given package. Starting from 10.5.0 and above stdout is being polluted by prepare scripts output and command itself.

> [email protected] prepare
> echo "Should not be visible"
[email protected]

Expected Behavior

npm pack should output to std only tarball file name as it was before otherwise its a breaking change.

Steps To Reproduce

  1. In any package add prepare script which writes to stdout
  2. Run npm pack and redirect stdout to file e.g. npm package > package-name
  3. Inspect package-name file content
  4. It should contain only package tarball name

Environment

  • npm: v10.8.0
  • Node.js: v20.13.1
  • OS Name: macOS 14.4.1
  • System Model Name: MacBook Pro
@falsyvalues falsyvalues added Bug thing that needs fixing Needs Triage needs review for next steps labels May 27, 2024
@milaninfy
Copy link
Contributor

milaninfy commented May 28, 2024

@falsyvalues This change was introduced as a fix to correct the regression. Follow discussion on this PR #7158 to get more background on this change. You can use this flag foreground-scripts or --silent to get expected output result.

@falsyvalues
Copy link
Author

@milaninfy Will I get the reasoning, result remains the same - breaking for end user. Also --silent won't help because it mutes only script call not the result.

{
    "prepare": "echo \"Noise\""
}
$ npm pack --silent
Noise
[email protected]

@milaninfy
Copy link
Contributor

milaninfy commented May 29, 2024

@falsyvalues Apologies I must have thought something else when I suggested --silent flag
but here is the output with npm pack --foreground-scripts=false > test2.txt.

~/workarea/rep $ npm pack --foreground-scripts=false > test2.txt
npm notice
npm notice 📦  [email protected]
npm notice Tarball Contents
npm notice 348B package.json
npm notice 361B rep-1.0.0.tgz
npm notice 91B test.txt
npm notice 0B test2.txt
npm notice Tarball Details
npm notice name: rep
npm notice version: 1.0.0
npm notice filename: rep-1.0.0.tgz
npm notice package size: 843 B
npm notice unpacked size: 800 B
npm notice shasum: 4c9cb5a1cdce1b1a5b8a25ea8fa8f7502693f68d
npm notice integrity: sha512-mhud3Gqlf4hPJ[...]pwBJEk6+zokgg==
npm notice total files: 4
npm notice

~/workarea/rep $ cat test2.txt 
rep-1.0.0.tgz

with --silent flag

~/workarea/rep $ npm pack --foreground-scripts=false --silent
rep-1.0.0.tgz

@milaninfy
Copy link
Contributor

This is currently working as intended,

@milaninfy milaninfy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants