Home > Software engineering >  Within a pnpm workspace, how to work with local copy of a fork of a public package
Within a pnpm workspace, how to work with local copy of a fork of a public package

Time:12-08

I'm using pnpm and its workspace feature to build several apps that share some code put in private libraries.

Aside private dependencies, I also reference a bunch of public packages from the npm registry.

This is working fine.

However, the public reference are sometime facing some bugs I'd like to help to resolve. This requires to work on a fork of the project before eventually submitting a PR.

Pnpm allows to declare a dependency to a git project, but how can I reference the local clone of the forked library ?

I'd like to avoid having to push any code to the forked project unless it has been tested locally.

Because I'm working within a pnpm workspace, the workspace is itself a whole git repo, which doesn't allow me to work with the fork within my workspace

CodePudding user response:

You can use a link. Just replace you dependency with a link with relative path to the forked repository. For instance:

{
  "dependencies": {
    "foo": "link:../foo"
  }
}

If this package is not a direct dependency of any of the project, use overrides:

{
  "pnpm": {
    "overrides": {
      "foo": "link:../foo"
    }
  }
}
  • Related