I use pnpm to manage npm project, and I modified the content of an installed package by accident, say, I cleared the content of node_modules/jquery/dist/jquery.js
.
The problem is no matter how i reinstall jquery(pnpm install jquery
), the content of this file is always empty. I even tried to delete jquery
from pnpm store ~/.pnpm-store/
, but that doesn't work(maybe I deleted wrong package)
Finally, I have to delete all the files in ~/.pnpm-store
, to download everything, it fixes my problem, but I want to know if there is any easier way to do it.
{ My answer will cover pnpm v2.16.2
}
Short answer: run pnpm install --force
. (pnpm update
might work as well)
Long answer. When you just run pnpm install
, pnpm compares the wanted shrinkwrap file (project/shrinkwrap.yaml
) to the current one (project/node_modules/.shrinkwrap.yaml
). They equal in your case, so node_modules
is not touched.
When --force
is used, packages are reverified and relinked from the store. Reverification means that its integrity is checked. You removed a file from jquery
, so verification will fail and the package will be reunpacked to the store and relinked to node_modules
.
Alternatively, you could remove your project's node_modules
and run pnpm install
. That would also check the integrity of jquery
before linking it to the store.
That being said, I think pnpm install jquery
should also probably verify the integrity of jquery. We'll create an issue for this in the pnpm repo.
And maybe we can add some additional commands for reverifying every package in node_modules
and re-unpacking all modified dependencies.
A related command currently available is pnpm store status which prints a list of mutated packages
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With