-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] Postinstall does not output anything from script (even with loglevel=silly) #3347
Comments
Lifecycle events do output when they run: ~/D/n/lifecycles $ npm i
> [email protected] preinstall
> echo foo preinstall script; touch lifecycle/preinstall
foo preinstall script
> [email protected] install
> echo foo install script; touch lifecycle/install
foo install script
> [email protected] postinstall
> echo foo postinstall script; touch lifecycle/postinstall
foo postinstall script
~/D/n/lifecycles $ npm -v
7.15.1 What is happening here is that the |
@wraithgar sorry, i dont not quite understand, do you mean that only the hooks of the root package (depth 0) are run, or only by the installed package (depth 1) (and not the transitive dependencies) just to make it an one-liner: i cannot get any log output from an postinstall script in npm 7.x when it successfully completes and to re-describe my problem: PS: the mentioned reproduction repository has 2 packages, the |
Sorry I see where I got confused. This is a situation that's still pretty confusing (even internally apparently) and we're working on improving it. If you install from a To get the output of lifecycle scripts that are suppressed, you need the The RFC I linked was the mirror of this problem, if you So TLDR |
here the full console output of trying to install the mentioned reproduction repository: Complete Console Outputsystem: Linux Mint 20.1
so basically there is no way to output the log of the background-scripts (even after script completion) with higher loglevel activated? only way is this thanks for mentioning this config option, i searched all over, but couldnt really find any way to force the log to appear again (looked into similar issues, suggested was an higher |
Yes this is the only way. |
Wherever you were instinctively looking for this would likely be a good candidate for updating the docs. If you would be so kind as to suggest an update to them via PR it would help us down the line. Docs for commands live here: https://github.com/npm/cli/tree/latest/docs/content |
@wraithgar with "similar issues" and "changelogs" i meant what i had found on google about this problem (stackoverflow, blog posts reporting on npm 7.x and some issues here and npm/config), but didnt really find an official changelog (that included this change and mention of the option), and where i "instinctively" (and after suggestions) looked was using an higher |
(Note: this is broken by npm/cli#3347)
(Note: this is broken by npm/cli#3347)
The migrations built on the fact that you could speak to the user when running the postinstall hook. Not so since npm7. npm/cli#3347 (comment) Change strategy for the migrations. Don't ask. Just do. If a migration encounters an error any console.log, console.error plus the error-message itself will be written to the console + the npm install debug log. Rely on this and change any process.exit(1) to throw instead. We can then catch any error at the top level, print some nice message and exit out cleanly. First up is the db.js in the v0.0.8 migration. Re-word so the base error is consistently included, remove any process.exit(1). Don't try to half-do migrations, either they all apply cleanly or we bail. Test plan: * node migrations/v0.0.8-v1.0.0/dbs.js && echo $? is zero.
Is there an existing issue for this?
Current Behavior
When installing a package with a
postinstall
script to output to console if the script logs something (thanks to other issues i already know that it was intentional to make it "quieter", but even with--loglevel silly
it did not output anything)PS: when the script errors, the output is logged, but if it does not error out it is not logged (with loglevel silly)
NPM Output
global npmrc:
Expected Behavior
The log from the script to be logged somehow to the console (even if it requires an different loglevel)
Steps To Reproduce
git clone https://github.com/hasezoey/npm-postinstall
cd npm-postinstall
cd root-package
npm install
/npm install --loglevel silly
Environment
The text was updated successfully, but these errors were encountered: