5

I have a script defined in the root-level package.json:

{
  "workspaces": [
    "packages/*"
  ],
  "scripts": {
    "clean": "rm -rf lib dist"
  },
  "private": true
}

I would like to run this script in the context of the the packages/example package, which does not define a clean script. (I want to reuse this script across all of my workspaces

I tried running npm -w packages/example run clean and npm run clean -w packages/example but these commands search for a clean script inside packages/example/package.json:

npm ERR! Error: Missing script: "clean"

To be clear, I want to delete the lib and dist folders from packages/example by running a script at the workspace root.

Note: I'm using this clean script as an example. The real scripts are more complicated and I don't want to duplicate them across all of the workspaces

grimsteel
  • 796
  • 1
  • 17

0 Answers0