I'm having some problems with yarn, on empty setups (when I do not have any versions of my libs on npm).
I've a multi-module project as structured bellow:
root # Yarn workspace
* packages
| * lib1-ws # Angular workspace
| | * projects
| | | * lib1
| | | * package.json
| | * package.json
| |
| * lib2-ws # Angular workspace
| | * projects
| | | * lib2
| | | * package.json # peer depends on lib1
| | * package.json # depends on lib1
| |
| * lib3-ws # Angular workspace
| * projects
| | * lib3
| | * package.json # peer depends on lib1
| * package.json # depends on lib1
|
* package.json
The projects lib2-ws and lib3-ws require lib1 to be build.
I was trying to release (install, build and publish) lib1 so that I can release lib2 and lib3.
But when I run yarn workspace lib1-ws install
or yarn install
(inside lib1-ws folder), yarn do try to install lib2-ws and lib3-ws as well, breaking the install operation with this error:
error Couldn't find package "lib1@^0.0.1" required by "[email protected]" on the "npm" registry.
Not sure what I'm missing, is there some command that I can run to ignore this workspace-aggregator
thing?
Thanks.
Yarn Workspaces is a feature that allows users to install dependencies from multiple package. json files in subfolders of a single root package. json file, all in one go. Yarn can also create symlinks between Workspaces that depend on each other, and will ensure the consistency and correctness of all directories.
This calls for using nohoist , which will put all of the packages we specify into the local node_modules for that package and not hoist them into the root workspace package. json.
Yarn converts dependencies from a package.json into a tree by resolving them recursively. An un-optimized dependency tree can be quite complex and many levels deep to reflect dependencies of dependencies. Some packages show up multiple times in the tree, possibly at conflicting versions.
We can also define which package manager Lerna uses, such as npm or yarn. The above command also initializes a package folder where the projects can be located. In the lerna. json file, add the npmClient option to specify yarn as the package manager.
It seems that I did not searched enough, after post this question, I read another question that give-me an idea.
My workspaces object became like this:
"workspaces": {
"packages": [
"packages/*",
"packages/**/projects/*"
]
}
And it works, now I can install without even build or publish.
[UPDATE]
Because some angular build particularities, after install all dependencies, the empty setup must execute some order (because yarn workspace create symlinks for the libs):
build lib1 then publish lib1
yarn workspace lib2-ws add lib1@latest
yarn workspace lib3-ws add lib1@latest
build lib2 then publish lib2
build lib3 then publish lib3
After this steps, my libs are ready on my verdaccio local repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With