Skip to content

[BUG] "npm rebuild" with v7 runs the postinstall script, whereas it did not run the postinstall script with npm v6 (can cause unexpected endless loop) #2670

@DeeDeeG

Description

@DeeDeeG

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:

  1. Make a new blank project: mkdir x && cd x && npm init -y
  2. Put this script in your package.json: "postinstall": "npm rebuild"
  3. Run npm install or npm rebuild
    i. npm install --verbose shows what's going on clearer.
  4. Observe: npm install runs postinstall which runs rebuild which triggers postinstall which runs rebuild... ♾️
  5. (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions