Skip to content

npm install --workspaces runs scripts in parent package #3598

@fasttime

Description

@fasttime

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

npm install --workspaces runs scripts defined in the package.json file of the parent package and ignores scripts in the package.json files of the workspace packages. The scripts are in order:

  • preinstall
  • install
  • postinstall
  • prepublish
  • preprepare
  • prepare
  • postprepare

Expected Behavior

npm install --workspaces should run scripts defined in the package.json files of the workspace packages, not those defined in the parent package.json.

Steps To Reproduce

Create a package with these two files:

./package.json

{
    "scripts": {
        "install": "echo INSTALLING PARENT"
    },
    "workspaces": [
        "./child"
    ]
}

./child/package.json

{
    "scripts": {
        "install": "echo INSTALLING CHILD"
    }
}

Run npm install --workspaces. This will output "INSTALLING PARENT" instead of "INSTALLING CHILD".

Environment

  • OS: ubuntu-latest
  • Node: 16.6.0
  • npm: 7.19.1

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