Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Within a pnpm workspace, how to work with local copy of a fork of a public package

Tags:

git

node.js

pnpm

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

like image 290
Steve B Avatar asked Sep 17 '25 19:09

Steve B


1 Answers

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"
    }
  }
}
like image 136
Zoltan Kochan Avatar answered Sep 20 '25 11:09

Zoltan Kochan