Skip to content

[BUG] Undocumented (?) change in prepublishOnly/prepare behavior in v7 #2668

@Conduitry

Description

@Conduitry

Current Behavior:

If there are both prepare and prepublishOnly scripts, then npm publish runs them in a different order in v7 than it did in v6.

Expected Behavior:

v7 should run these in the same order as v6, or this difference should be documented somewhere.

Steps To Reproduce:

  1. In an empty directory, create a package.json containing:
{
        "name": "test",
        "version": "0.0.0",
        "scripts": {
                "prepare": "echo prepare >> scripts.log",
                "prepublishOnly": "echo prepublishOnly >> scripts.log"
        }
}
  1. Run npm publish (aborting out of 2FA prompt, etc.)
  2. cat scripts.log

On npm@6.14.11, this file contains:

prepare
prepublishOnly

On npm@7.5.3, this file contains:

prepublishOnly
prepare

Is this an intended change or is it a bug? I didn't see anything in the 7.0.0 changelog about this, nor did I see any relevant differences between https://docs.npmjs.com/cli/v6/using-npm/scripts and https://docs.npmjs.com/cli/v7/using-npm/scripts.

Environment:

  • OS: Ubuntu 20.04
  • Node: 15.8.0
  • npm: 7.5.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 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