npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.46k stars 3.15k forks source link

[BUG] Post install hook not running from dependency #6252

Open MrTibbles opened 1 year ago

MrTibbles commented 1 year ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

I have package A that has package B listed as a dependency, package B has a post install hook defined. When package B is installed directly by a project the post install script fires as expected. However when package A is installed the post install script for package B is not being called. I have passed --foreground-scripts to ensure nothing is being missed.

Expected Behavior

When a package has a dependency that has a post install hook defined, that post install hook should be called when the package is installed directly OR as a dependency.

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

; "user" config from /Users/XXXXX/.npmrc

dormammun commented 1 year ago

Hello @MrTibbles did you fix this? I currently face something similar, but on Mac and Windows WSL there is no such issue.

https://github.com/npm/cli/issues/6365 You can visit for more details, in next I will debug npm cli)

MrTibbles commented 1 year ago

Hi @dormammun, i have not resolved this issue no; sadly. Yarn behaves as expected, so we have been encouraging our users to prefer yarn.

bennypowers commented 1 year ago

I have the opposite problem - I only want postinstall to run after npm ci in the repo dir for packageB - I don't want users of packageB to run postinstall.

This is indeed what happens when users install packageB normally i.e. without configuring npmrc. HOWEVER, when they use a certain custom npm registry in the registry= field of npmrc (can't share the url, sorry), the postinstall script runs and they get a "command not found" error