Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a package from pnpm store, or force re-download it?

Tags:

pnpm

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.

like image 893
Freewind Avatar asked Oct 01 '18 15:10

Freewind


1 Answers

{ 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

like image 88
Zoltan Kochan Avatar answered Sep 18 '22 03:09

Zoltan Kochan