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 rebuild" runs any symlinked package's lifecycle scripts twice. #2905

Closed
DeeDeeG opened this issue Mar 19, 2021 · 0 comments · Fixed by #4529
Closed

[BUG] "npm rebuild" runs any symlinked package's lifecycle scripts twice. #2905

DeeDeeG opened this issue Mar 19, 2021 · 0 comments · Fixed by #4529
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@DeeDeeG
Copy link

DeeDeeG commented Mar 19, 2021

Current Behavior:

A package dependency installed as a symlink will get its lifecycle scripts (such as postinstall) run twice when running the npm rebuild subcommand of npm.

Expected Behavior:

Lifecycle scripts should probably only be run once.

Steps To Reproduce:

Set up a minimal/dummy dependency with lifecycle scripts:

  • mkdir test && cd test && npm init -y
  • mkdir dependency && cd dependency && npm init -y
  • Add this as a preinstall script for the dependency dummy package: "preinstall": "echo 'You will see this twice!'

Add the dummy package with lifecycle scripts as a symlinked dependency:

  • cd ..
  • npm install ./dependency

Run npm rebuild and verify that the lifecycle script runs twice:

  • npm rebuild --foreground-scripts

Example output:

% npm rebuild --foreground-scripts

> dependency@1.0.0 preinstall
> echo 'You will see this twice!'

You will see this twice!

> dependency@1.0.0 preinstall
> echo 'You will see this twice!'

You will see this twice!
rebuilt dependencies successfully

Environment:

  • OS: macOS Catalina 10.15.7
  • Node: v15.12.0
  • npm: 7.6.3
@DeeDeeG DeeDeeG 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 Mar 19, 2021
@darcyclarke darcyclarke added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels May 14, 2021
@wraithgar wraithgar self-assigned this Mar 9, 2022
ruyadorno added a commit to ruyadorno/cli that referenced this issue May 10, 2022
- Fixes running proper lifecycle scripts for linked deps and
  workspaces.
- Added test to validate lifecycle scripts don't run twice
  for linked deps
- Tweaked "reify workspaces bin files" test to also validate
  proper lifecycle scripts ran before check for linked bins.
- Tweaked reify test running lifecycle scripts of unchanged link
  nodes to also validate that the install lifecycle scripts are
  also called.

Fixes: npm#4277
Fixes: npm#4552
Fixes: npm/statusboard#439
Relates to: npm#2905
ruyadorno added a commit to ruyadorno/cli that referenced this issue May 10, 2022
- Fixes running proper lifecycle scripts for linked deps and
  workspaces.
- Added test to validate lifecycle scripts don't run twice
  for linked deps
- Tweaked "reify workspaces bin files" test to also validate
  proper lifecycle scripts ran before check for linked bins.
- Tweaked reify test running lifecycle scripts of unchanged link
  nodes to also validate that the install lifecycle scripts are
  also called.

Fixes: npm#4277
Fixes: npm#4552
Fixes: npm/statusboard#439
Relates to: npm#2905
wraithgar pushed a commit that referenced this issue May 10, 2022
- Fixes running proper lifecycle scripts for linked deps and
  workspaces.
- Added test to validate lifecycle scripts don't run twice
  for linked deps
- Tweaked "reify workspaces bin files" test to also validate
  proper lifecycle scripts ran before check for linked bins.
- Tweaked reify test running lifecycle scripts of unchanged link
  nodes to also validate that the install lifecycle scripts are
  also called.

Fixes: #4277
Fixes: #4552
Fixes: npm/statusboard#439
Relates to: #2905
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants