lernanpm-workspaces

Lerna run script with omitting dev dependencies


We are using Lerna in a typescript mono repo.
I have package A which has dev dependency on package B, which has its own dependencies.
When I build package A for production usage, I use the following:

npm ci --include-workspace-root --omit=dev -w A
npm run lerna -- run build --include-dependencies --scope A

The problem is that lerna runs "build" on package B although package B wasn't installed.
Is there a way to make "lerna run" ignore dev dependencies it finds in the scope of A?


Solution

  • You probably want to use --exclude-dependents but you will also need --since because it says that it doesn't work without it

    --exclude-dependents Exclude all transitive dependents when running a command with --since, overriding the default "changed" algorithm.

    This flag has no effect without --since, and will throw an error in that case.

    see Lerna-Lite filter packages docs