I like to share my struggle in uninstalling a package from my project. I believe it may add value to the answers above.
I evaluated a package named react-router
in one of my projects. Later I decided to remove it.
I wanted to remove the package first and then remove its reference from my code.
I tried npm uninstall
and npm prune
. However, in both cases, it failed to remove the package from my node-modules
folder.
I removed the reference of react-router
from the code and tried again. I still couldn't remove it with the above command.
After some digging, I found that I also installed react-router-dom
that uses the package react-router
. So I had to remove it first using the commands above. Only then, I was able to remove the react-router
.
I find it strange that npm uninstall
does not remove packages if they are referred. I think, if it allows, I don't have to manually find the usage of the package by searching them in class instead of IDE/Lint can help me find it much more easily.