Run `yarn remove <dependency_name>` to remove dependency, but yarn.lock still shows the removed dependency

Viewed 981

In my node.js project, I had using yarn installed the dependency @nestjs/jwt, now I want to uninstall it since I am not using it.

I run yarn remove @nestjs/jwt. It was successful. I checked my package.json, it was removed. But when I check the yarn.lock file, it is still showing. Why is that?

My git add -p yarn.lock shows me:


-"@nestjs/jwt@8.0.0", "@nestjs/jwt@^8.0.0":
+"@nestjs/jwt@^8.0.0":
   version "8.0.0"
   resolved "https://registry.yarnpkg.com/@nestjs/jwt/-/jwt-8.0.0.tgz#6c811c17634252dd1qcd5dabf409db4692b812da"
   integrity sha512-fz2LQgYY2zmuD8S+8UE215anwKyXlnB/1FwJMLVR47clNfMeFMK8WCxmn6xd0hF5JKuV1crO6FVabb1qWzDxqQ==
2 Answers

Besides packages you explicitly install, packages depend on other packages. To see a graph of any dependents of this package you have installed, do:

yarn why @nestjs/jwt -R

Yarn.lock is what yarn uses to know what versions of each dependency are installed so it can get those exact versions again when you run yarn install on a new machine. Try running 'yarn upgrade'. This should create a new yarn.lock file without those dependencies.

Related