Let us say I have an nx/lerna monorepo with two projects, A and B, where A depends on B. So the package.json-s look like this
{
"name": "A",
"version": "1.2.3",
...
"dependencies": {
"B": "*"
}
}
and
{
"name": "B",
"version": "1.2.3",
...
}
When I run npx lerna version 1.2.4, the command overrides my no-version reference, i.e. A's package.json becomes
{
"name": "A",
"version": "1.2.4",
...
"dependencies": {
"B": "^1.2.4"
}
}
while I would want it to become
{
"name": "A",
"version": "1.2.4",
...
"dependencies": {
"B": "*"
}
}
Is there a parameter that will leave the * alone?
You should use the
workspace:protocol instead, it's supported by both Lerna & Lerna-Lite. On the package managers side, this protocol is supported by Yarn and pnpm package managers (npm does not yet support it), for example take a look at pnpm workspace: docs and if you go ahead with for exampleworkspace:*, then that will remain in place except when of course when publishing since the real version number must be used, otherwise theworkspace:*remains untouched (you can also use^or~instead of*but the latter is more commonly used).The other advantage of this protocol is that it will always use the local package copy (or symlink actually) instead of always trying to download it form npm first (which is what
*would do) and another great benefit is that the lock file never changes for the dependencies withworkspace:*since that is what is kept in the lock file (again only at publish time does the real version number appears for external users of your lib).