node.jsnpmlerna

Lerna publish fails "No matching version found" when used in another workspace


I have a project with two workspaces /packages/core and /packages/client and client has core added as a dependency:

{
  "name": "core",
  "version": "1.0.0-alpha.9",
  "dependencies": {},
}

{
  "name": "client",
  "version": "1.0.0-alpha.9",
  "dependencies": {
    "core": "^1.0.0-alpha.9",
  },
}

If I make a change to both packages, and then try to lerna publish I get an npm error saying the package doesnt exist:

npx lerna publish --no-private

lerna ERR! npm ERR! code ETARGET
lerna ERR! npm ERR! notarget No matching version found for core@^1.0.0-alpha.10.
lerna ERR! npm ERR! notarget In most cases you or one of your dependencies are requesting
lerna ERR! npm ERR! notarget a package version that doesn't exist.
lerna ERR! 

Since lerna doesn't clean up on a failed publish, inspecting the package.json's all the files are properly updated to the new version:

{
  "name": "core",
  "version": "1.0.0-alpha.10",
  "dependencies": {},
}

{
  "name": "client",
  "version": "1.0.0-alpha.10",
  "dependencies": {
    "core": "^1.0.0-alpha.10",
  },
}

How do I properly use a workspace in another workspace without lerna failing to publish?

I realize this is more of an issue with npm than lerna. If I do npm i core -w client after changing the core version manually, it installs fine. Its only when the version is changed and npm i is called that npm cannot seem to figure out that it should still be linking to the local version and not going to the registry.


Solution

  • Switched over to yarn and it works fine.