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] No "postinstall" on global packages anymore #2194

Closed
voltuer opened this issue Nov 18, 2020 · 12 comments
Closed

[BUG] No "postinstall" on global packages anymore #2194

voltuer opened this issue Nov 18, 2020 · 12 comments
Assignees
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@voltuer
Copy link

voltuer commented Nov 18, 2020

Current Behavior:

I'm making a global cli tool that asks you for your language preference upon install but since NPM 7 it doesn't run the postinstall script anymore

Expected Behavior:

In NPM 6 it works just fine

Steps To Reproduce:

npm i -g dnd

Environment:

macOS Big Sur, npm 7

@voltuer voltuer 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 Nov 18, 2020
@ljharb
Copy link
Contributor

ljharb commented Nov 18, 2020

Are you sure it’s not running it, as opposed to not displaying any output?

@voltuer
Copy link
Author

voltuer commented Nov 27, 2020

Apparently it is running, but I need to show staff to the user, as it worked before v7

@ljharb
Copy link
Contributor

ljharb commented Nov 27, 2020

That was intentionally suppressed in v7, to prevent spamming users with ads and similar messages. You’ll have to wait to show the users the output until the first time they use your tool.

@voltuer
Copy link
Author

voltuer commented Nov 28, 2020

Could you please share a link to an official announcement of this change? I will need to explain this to my client

@ljharb
Copy link
Contributor

ljharb commented Nov 28, 2020

https://blog.npmjs.org/post/626173315965468672/npm-v7-series-beta-release-and-semver-major is the announcement, but it may not mention this one specifically.

@ljharb
Copy link
Contributor

ljharb commented Dec 1, 2020

Ah, I didn’t realize it wasn’t actually running them globally.

@darcyclarke darcyclarke self-assigned this Dec 1, 2020
@voltuer
Copy link
Author

voltuer commented Dec 9, 2020

So how am I supposed to run a script that needs user input when installing my script?

@ljharb
Copy link
Contributor

ljharb commented Dec 9, 2020

Generally speaking, installs aren't a place where user input is available - consider installs in CI.

@voltuer
Copy link
Author

voltuer commented Dec 11, 2020

good point, hadn't seen it that way

@Apollon77
Copy link

We also have the same issue on non-global but "npm i in a directly by using the local package.json" ... it seems that postinstall and install is not executed

@sinedied
Copy link

The issue can be replicated also with Decktape with npm i -g [email protected]

  • On NPM v6, the pupeeter dependency postinstall script works fine (downloads a chromium bin)
  • On NPM v7, the pupeeter dependency postinstall script is NOT executed - not just muted, as install finishes quickly instead of donwloading a huge bin on my machine.

@darcyclarke
Copy link
Contributor

The originating issue is actually the intended experience in v7; If you want to see when scripts are run, you can add the flag --foreground-scripts.

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 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

5 participants