Skip to content

[BUG] workspace scripts do not propagate exit codes #6506

@JamesHenry

Description

@JamesHenry

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Minimal Setup

package.json

{
  "workspaces": ["child"],
  "scripts": {
    "exit-100": "exit 100"
  }
}

child/package.json

{
  "scripts": {
    "exit-100": "exit 100"
  }
}

Repro Steps

Behavior in root:

npm run exit-100
echo $? # correctly returns 100

Behavior in workspace:

npm run exit-100 --workspace child
echo $? # incorrectly returns 1

# OR

cd child
npm run exit-100
echo $? # incorrectly returns 1

Also note, if you amend the root package.json to remove the workspaces and then repeat those final steps:

cd child
npm run exit-100
echo $? # (now without workspaces config in the level above) correctly returns 100

Environment

  • npm: 9.5.0
  • Node.js: 18.15.0
  • OS Name: macOS 13.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 9.xwork is associated with a specific npm 9 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions