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 install does not run postinstall nor does it show name & version of installed pkg #3647

Closed
1 task done
JoernBerkefeld opened this issue Aug 13, 2021 · 14 comments
Closed
1 task done
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

@JoernBerkefeld
Copy link

JoernBerkefeld commented Aug 13, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

when running npm install ... with a local package or a package on npm's servers it does not execute whatever is in scripts.postinstall

image

for
image

Expected Behavior

in the 6.x releases it would state the line found in postinstall while executing it, means for the above example one should see

echo 'test postinstall'
test postinstall

It also printed the name & version of the package it just installed.

While the above example is trivial, it also extends to linking / running a *.js file with more complex logic via postinstall.

In #1905 a similar issue was mentioned for npm ci but somehow it still worked for npm install back then.

Steps To Reproduce

  1. prep a new package with the following package.json:
{
  "name": "npm-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "postinstall": "echo 'test postinstall'"
  },
  "author": "",
  "license": "ISC"
}
  1. try installing it into another package.
  2. see how it's not executing postinstall

Environment

  • OS: Windows 10
  • Node: 14.17.5
  • npm: 7.20.6
@JoernBerkefeld JoernBerkefeld 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 Aug 13, 2021
@ljharb
Copy link
Contributor

ljharb commented Aug 13, 2021

Are you sure it's not executing it but suppressing output? In npm 7, dependencies can't spam the console with postinstall messages.

@isaacs
Copy link
Contributor

isaacs commented Aug 17, 2021

It does execute. Run with --foreground-scripts or --loglevel=verbose and you'll see proof of this. We suppress the output if it exits with a zero status code, so that we can run multiple build scripts in parallel and not spam your terminal.

@isaacs isaacs closed this as completed Aug 17, 2021
@JoernBerkefeld
Copy link
Author

hm. so what options are remaining to show an intro message after somebody executes npm install myPkg ?
i get why this would be silenced during a generic npm install execution but do not understand why it is when I install a specific package

@ljharb
Copy link
Contributor

ljharb commented Aug 18, 2021

The user could opt in to it, but there are no intro message options. Tell them what you need to tell them in your docs.

@JoernBerkefeld
Copy link
Author

hm. No, that's not correct. there isn't really an option to "opt-in" for the user because the above commands both show way more info than what the actually installed plugin is executing in the postinstall. in our case, we urge users to reload their IDE which is constantly forgotten despite being in the docs.

--foreground-scripts does show ALL the postinstall messages of sub-dependencies AND also npm warns. Means the screen is spammed with mostly unreadable info.
meanwhile loglevel=verbose is absolutely useless for what I asked... I'm sure you know that.

And even without both parameters, the current output doesn't even acknowledge what version one just installed. While 6.x basically did what --foreground-scripts is doing, it also printed the version of the installed package which --foreground-scripts in 7.x does not, nor does the standard output for that matter.

--> while you obviously intended good I don't believe that's what you accomplished here and urge to rethink it.

@ljharb
Copy link
Contributor

ljharb commented Aug 18, 2021

What is your use case for an intro message? As a user, I would never, ever want that.

@JoernBerkefeld
Copy link
Author

" in our case, we urge users to reload their IDE which is constantly forgotten despite being in the docs."
why? because our package works best together with VSCode (clearly mentioned in the docs) and requires a list of vscode extensions to actually provide the service the user expects (eslint, prettier, ...). The restart of the IDE makes vscode prompt the user to install or review the recommendations

@ljharb
Copy link
Contributor

ljharb commented Aug 18, 2021

If they won't read the docs then why would they read the install message?

@JoernBerkefeld
Copy link
Author

:| #motivation

people are waiting for the install to finalize and right now it doesn't even output a "hey, what you just tried installing is now installed" anymore - contrary to 6.x

and whatever message I output as part of postinstall can (& does) use colors, making sure people can see it easily.
The docs on the other hand are veeeery long and people tend to skip steps unintentionally.

@JoernBerkefeld
Copy link
Author

im requesting to re-open this issue

@atomless
Copy link

Please re-open this issue. Running npm 8.1.0 and pre/post npm scripts are no longer able to echo to the terminal. This is a huge regression.

@ljharb
Copy link
Contributor

ljharb commented Oct 28, 2021

@atomless this happened in v7.0.0 and was very intentional, and I don't believe there's any plans to change it.

@ZyJoey
Copy link

ZyJoey commented Jan 21, 2022

I have the same problem. In my case, the postinstall script will be executed a few minutes. So I'd like to print some messages for user to tell them the dependency is executing something expected rather than still frame. If not it will makes them feel meeting unknown error.

@hbaldwinRPT
Copy link

It does execute. Run with --foreground-scripts or --loglevel=verbose and you'll see proof of this. We suppress the output if it exits with a zero status code, so that we can run multiple build scripts in parallel and not spam your terminal.

It is also not executing then. i have run all types of higher log levels and there is nothing to indicate that it is being run, nor is there any creation of the items which neccesitate the use of the postinstall.

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

6 participants