Search code examples
packagemonorepopnpm

"<PackageA> is in the dependencies but no package named <PackageA> is present in the workspace" - Error when running pnpm install


I have multiple packages in a monorepo setup with pnpm 8.14.1 and Lerna 7.3.0. I'm running the command pnpm install and getting the error:

ERR_PNPM_WORKSPACE_PKG_NOT_FOUND  In packages\<PackageB>: "@mynamespace/<PackageA>@workspace:*" is in the dependencies but no package named "@mynamespace/<PackageA>" is present in the workspace

I have multiple packages in my monorepo and they're all working fine. I have just added the <PackageA> and for some reason my <PackageB> is not recognizing it.

Does anyone have an idea what the reason could be?


Solution

  • The error turned out the be due to a missing namespace in the package name in the package.json file.

    Here is what I had:

      ...
      "name": "PackageA",
      ...
    

    And here is what it should have been:

      ...
      "name": "@mynamespace/PackageA",
      ...