#1458·lerna

Support `--scope <packages-folder>/*`

Author: MatejBranskyCreated Jun 8, 2018Updated Mar 13, 2026
Labelstype: feature

It seems that it doesn't work if you want, for example, call lerna exec --scope packages/* (script for all packages in ./packages/ folder. I want this because I have two folders: one for packages and one for examples. Because of that I have to, temporarily, use prefixes in names (packages/package-components-foo, packages/package-utils) with lerna exec --scope package-* -- babel src --out-dir lib.

Example:

npm script: lerna exec --scope packages/* -- babel src --out-dir lib

Expected Behavior

Calls for all packages in ./packages folder.

Current Behavior

Error: No packages found that match scope 'packages/*'.

Possible Solution

I don't know how to implement it but it should be possible.

root package.json

(only specific for monorepo with Yarn workspaces)

json
{
  "workspaces": ["examples/*", "packages/*"],
}

lerna.json

json
{
  "lerna": "2.11.0",
  "version": "0.0.0",
  "npmClient": "yarn",
  "useWorkspaces": true
}

lerna-debug.log

txt
0 silly input [ 'babel', 'src', '--out-dir', 'lib', '--watch' ]
1 silly flags { _: [ 'exec' ],
1 silly flags   'reject-cycles': false,
1 silly flags   rejectCycles: false,
1 silly flags   stream: true,
1 silly flags   parallel: true,
1 silly flags   scope: 'packages/*',
1 silly flags   since: '',
1 silly flags   command: 'babel',
1 silly flags   args: [ 'src', '--out-dir', 'lib', '--watch' ] }
2 verbose rootPath C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope
3 info version 2.11.0
4 silly existsSync C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\VERSION
5 info scope packages/*
6 error EPACKAGES Errored while collecting packages and package graph
7 error Error: No packages found that match scope 'packages/*'
7 error     at Function.filterPackages (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\lerna\lib\PackageUtilities.js:252:17)
7 error     at ExecCommand.runPreparations (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\lerna\lib\Command.js:333:60)
7 error     at C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\lerna\lib\Command.js:209:18
7 error     at new Promise (<anonymous>)
7 error     at ExecCommand.run (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\lerna\lib\Command.js:193:14)
7 error     at Object.handler (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\lerna\lib\commands\ExecCommand.js:45:14)
7 error     at Object.self.runCommand (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\yargs\lib\command.js:233:22)
7 error     at Object.Yargs.self._parseArgs (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\yargs\yargs.js:990:30)
7 error     at Object.Yargs.self.parse (C:\Users\m24ma\Documents\projekty\_sandbox\lerna\scope\node_modules\yargs\yargs.js:532:23)

Context

It is useful when you have special directory for apps and special one for packages. These two groups maybe needs totally different bundle configs and scripts.

Your Environment

Executable Version
lerna --version 2.11.0
npm --version 6.1.0
yarn --version 1.7.0
node --version 10.3.0
OS Version
Windows 10 1803