npm link and yarn link are both "not the best". I run into issues with them quite often. Now I have read about pnpm and its local storage. I wonder if pnpm can help me remedy my npm link issues in the following case:
I have two projects in separate repos, and therefore not in one single workspace. One is the "app", the other one a "lib" which is used in the app. Now, I want to somehow build the lib and use the fresh build within app without publishing it to the global npm registry. Thats what I used yarn link for quite often. However, I wonder if pnpm offers me a way to "publish to local store".
So my question: Is it possible to publish build packages to the local pnpm repo in such a way, that "pnpm install lib" within the "app" will successfully install the fresh built "lib" package?
There are three ways.
You may use the file protocol to reference your local lib:
{
"dependencies": {
"lib": "file:../lib"
}
}
In this case, pnpm will create hard links to each file of lib. It will look like lib is copied to the node_modules of your app.
You may use the link protocol:
{
"dependencies": {
"lib": "link:../lib"
}
}
In this case, pnpm will create a symlink to your lib in app/node_modules/lib
.
Or you may pack your lib into a tarball with pnpm pack
and then install it through the file protocol
{
"dependencies": {
"lib": "file:../lib/lib-1.0.0.tgz"
}
}
There is no way to "publish to a local store".