How do I publish a public lib locally without adding a `run` script just for me?

Here's the context: I've built my own public library. I'm also building an app that uses this library. I may need to modify the library to fit the app's use case, and until the dust settles on that effort, I do not want to npm publish the library while I iterate on this use case. When lib is modified, I'd like to publish locally so my app can get the latest code. The only way I know how to do that is to add a npm run build-and-publish-locally-because-i-am-iterating-on-app to lib's package.json. That feels wrong: lib is open source, intended to be used by strangers, and I don't want to accidentally publish that script if I need to fix an unexpected, unrelated lib bug. Is there a better approach to this problem? I don't think I'm the first person to create my own library for my own app. How do most handle this?
4 Replies
DanKaplanSES
DanKaplanSES10mo ago
According to the NPM documentation, this is a good use case for npm link or npm install <relativePathToLib>. Unfortunately, I've run into bugs that make this an impossibility. Fortunately, there is a library that addresses this bug named yalc.
Nihan
Nihan10mo ago
Consider using pnpm then
Nihan
Nihan10mo ago
pnpm add | pnpm
Installs a package and any packages that it depends on.
DanKaplanSES
DanKaplanSES10mo ago
I don't see anything in that link suggesting it would make a difference
Want results from more Discord servers?
Add your server