`lerna run` doesn't execute peers in topological order
See original GitHub issueI have several packages, most of which only depend on the core package at the moment. Each package is individually built using the Angular CLI.
@denverhjs/core
@denverhjs/foo
@denverhjs/baz
@denverhjs/bat
Expected Behavior
Lerna can determine that @denverhjs/core
must be built before any of the packages that list it in their package.json
peerDependencies list.
Current Behavior
Executing the build script yields the following error output:
lerna ERR! npm run build stderr: src/lib/bat.module.ts(3,37): error TS2307: Cannot find module ‘@denverhjs/core’. src/lib/bat.module.ts(8,5): Error during template compile of ‘BatModule’ Could not resolve @denverhjs/core relative to [object Object]… src/lib/bat.module.ts(8,5): Error during template compile of ‘BatModule’ Could not resolve @denverhjs/core relative to [object Object]…
Error: src/lib/bat.module.ts(3,37): error TS2307: Cannot find module ‘@denverhjs/core’. src/lib/bat.module.ts(8,5): Error during template compile of ‘BatModule’ Could not resolve @denverhjs/core relative to [object Object]… src/lib/bat.module.ts(8,5): Error during template compile of ‘BatModule’ Could not resolve @denverhjs/core relative to [object Object]…
at Object.<anonymous> (/Users/denverb/workspace/personal/lerna-demo/node_modules/ng-packagr/lib/ngc/compile-source-files.js:65:19) at Generator.next (<anonymous>) at fulfilled (/Users/denverb/workspace/personal/lerna-demo/node_modules/ng-packagr/lib/ngc/compile-source-files.js:4:58) at <anonymous>
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @denverhjs/bat@0.0.1 build:
ng build bat
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @denverhjs/bat@0.0.1 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install?npm ERR! A complete log of this run can be found in: npm ERR! /Users/denverb/.npm/_logs/2019-03-25T18_53_54_969Z-debug.log
lerna ERR! npm run build exited 1 in ‘@denverhjs/bat’ lerna WARN complete Waiting for 3 child processes to exit. CTRL-C to exit immediately. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! lerna-demo@0.0.0 build:
lerna run build
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the lerna-demo@0.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! /Users/denverb/.npm/_logs/2019-03-25T18_53_55_004Z-debug.log
Possible Solution
Execution proceeds without error when the command:
lerna run build --scope @denverhjs/core && lerna run build --ignore @denverhjs/core
However that is not sustainable as the dependency graph grows in depth.
Steps to Reproduce (for bugs)
- Fork and clone this repo: https://github.com/denver-HJS/lerna-demo
- execute
npm run build
orlerna run build
lerna.json
{
"packages": [
"projects/*"
],
"version": "independent"
}
Context
I’m trying to leverage this great library to provide a CI solution for an Angular monorepo that contains multiple Angular NPM packages.
Your Environment
Executable | Version |
---|---|
lerna --version |
3.13.1 |
npm --version |
6.4.0 |
node --version |
9.11.1 |
OS | Version |
---|---|
NAME | VERSION |
macOS Sierra | 10.13.6 |
Windows 10 | 1607 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (2 by maintainers)
Top GitHub Comments
@evocateur, thank you for reading that closer than I did! 😃
It does work correctly now when I’ve added the desired higher order dependency to the leaf packages’
devDependencies
list. Thank you for the help.I have similar issue where in there packages |- module#1 |- module#2 |- module#3
now when I try to run lerna run build Since module#3 is marked as dependency of module#1, command build needs to be executed first for module#3 so it to be available for consumption for module#1
Question - Is this supported in lernaJS ? If yes, how can i achieve it?