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] prepack/postpack output is incorrectly suppressed #6816

Closed
2 tasks done
ljharb opened this issue Sep 17, 2023 · 0 comments · Fixed by #7158
Closed
2 tasks done

[BUG] prepack/postpack output is incorrectly suppressed #6816

ljharb opened this issue Sep 17, 2023 · 0 comments · Fixed by #7158
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release Release 10.x

Comments

@ljharb
Copy link
Contributor

ljharb commented Sep 17, 2023

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

With this example package.json in an empty dir:

{
  "private": true,
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "prepack": "echo prepack!",
    "postpack": "echo postpack!"
  }
}

and run npm pack --dry-run. You should see the following output, which appears in npm < 9:

> foo@0.0.0 prepack
> echo prepack!

prepack!

> foo@0.0.0 postpack
> echo postpack!

postpack!
npm notice 
npm notice 📦  foo@0.0.0
npm notice === Tarball Contents === 
npm notice 234B package.json
npm notice === Tarball Details === 
npm notice name:          foo                                     
npm notice version:       0.0.0                                   
npm notice filename:      foo-0.0.0.tgz                           
npm notice package size:  236 B                                   
npm notice unpacked size: 234 B                                   
npm notice shasum:        ba4102210bf70a017cd510276f01cc0c4b5f68d0
npm notice integrity:     sha512-/s4lXyjWKoW7y[...]adUe23zB6HEkw==
npm notice total files:   1                                       
npm notice 
foo-0.0.0.tgz

However, in npm >= 9.0, i get this output:

npm notice 
npm notice 📦  foo@0.0.0
npm notice === Tarball Contents === 
npm notice 234B package.json
npm notice === Tarball Details === 
npm notice name:          foo                                     
npm notice version:       0.0.0                                   
npm notice filename:      foo-0.0.0.tgz                           
npm notice package size:  236 B                                   
npm notice unpacked size: 234 B                                   
npm notice shasum:        ba4102210bf70a017cd510276f01cc0c4b5f68d0
npm notice integrity:     sha512-/s4lXyjWKoW7y[...]adUe23zB6HEkw==
npm notice total files:   1                                       
npm notice 
foo-0.0.0.tgz

Expected Behavior

npm 9+ doesn't suppress output in prepack/postpack scripts (and more broadly, in any lifecycle script that wouldn't be shown to a user who runs npm install/npm ci such that this project is installed (meaning, my own postinstall/preinstall/prepare scripts should always show output, but nobody else's should)

Steps To Reproduce

see above

Environment

  • npm: 10.1.0
  • Node.js: 20.5.1
  • OS Name: Mac OS
  • System Model Name: Macbook Pro
  • npm config: n/a as long as ignore-scripts isn't set
@ljharb ljharb added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Sep 17, 2023
@lukekarrys lukekarrys added the Release 9.x work is associated with a specific npm 9 release label Oct 6, 2023
ljharb added a commit to ljharb/cli that referenced this issue Jan 18, 2024
ljharb added a commit to ljharb/cli that referenced this issue Jan 18, 2024
ljharb added a commit to ljharb/cli that referenced this issue Jan 19, 2024
ljharb added a commit to ljharb/cli that referenced this issue Jan 19, 2024
ljharb added a commit to ljharb/cli that referenced this issue Jan 19, 2024
ljharb added a commit to ljharb/cli that referenced this issue Jan 19, 2024
ljharb added a commit to ljharb/cli that referenced this issue Feb 27, 2024
ljharb added a commit to ljharb/cli that referenced this issue Feb 27, 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 Release 9.x work is associated with a specific npm 9 release Release 10.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants