Current Behavior:
Putting npm rebuild in a postinstall script can cause an infinite loop with npm v7.
Expected Behavior:
npm rebuild used to not trigger the postinstall script (so, no infinite loop) with npm v6.
Steps To Reproduce:
- Make a new blank project:
mkdir x && cd x && npm init -y
- Put this script in your
package.json: "postinstall": "npm rebuild"
- Run
npm install or npm rebuild
i. npm install --verbose shows what's going on clearer.
- Observe:
npm install runs postinstall which runs rebuild which triggers postinstall which runs rebuild... ♾️
- (Optional): Open a task manager or system monitor to see that many copies of npm are spawned recursively.
Environment:
- OS: Tested on: macOS 10.15.7, Windows 10, Ubuntu 20.04 (and happens to some lesser extent on Windows Subsystem for Linux)
- Node: Tested on: 12.20
- npm: 7.1.1 and newer are affected