cli
cli copied to clipboard
[BUG] workspace scripts do not propagate exit codes
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] 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
I have a minimal reproduction repo here as well: https://github.com/mehulkar/turbo-issue-5098 with node 20.2 + npm 9.6.
@mehulkar my guess is you are actually running into https://github.com/npm/cli/issues/6399 and not what I am describing here