-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[BUG] "npm rebuild" runs any symlinked package's lifecycle scripts twice. #2905
Copy link
Copy link
Closed
Labels
Bugthing that needs fixingthing that needs fixingPriority 1high priority issuehigh priority issueRelease 7.xwork is associated with a specific npm 7 releasework is associated with a specific npm 7 release
Description
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 -ymkdir dependency && cd dependency && npm init -y- Add this as a preinstall script for the
dependencydummy 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
> [email protected] preinstall
> echo 'You will see this twice!'
You will see this twice!
> [email protected] preinstall
> echo 'You will see this twice!'
You will see this twice!
rebuilt dependencies successfullyEnvironment:
- OS: macOS Catalina 10.15.7
- Node: v15.12.0
- npm: 7.6.3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bugthing that needs fixingthing that needs fixingPriority 1high priority issuehigh priority issueRelease 7.xwork is associated with a specific npm 7 releasework is associated with a specific npm 7 release