Completely uninstalling npm package

Jun 17, 2022·Quick read

Completely uninstalling npm package


Today I ran into an interesting issue with an NPM package prisma.Turned out it doesn't have much to do with Prisma package, rather it was related to some reference file in /usr/local/bin/ that was in some weird way referencing some installtion of prisma. A little contextI have been playing around with Prisma for years now, though, after stepping away from it for a while, a new major version landed and as the major versions do, it introduced some breaking changes. So I needed to upgrade the package.No matter what I did (npm remove, npm uninstall, npm -g ..., restarting computer afterwards, nothing seemed to really remove the package, even though the npm why prisma was suggesting that no prisma is installed, so did the npm list -g --depth=0 - everything seemed to be uninstalled correctly, yet I was able to run prisma -v and that returned an outdated version - what the –?? So I started digging and it started to seem that it has nothing to do with Prisma, and has everything to do with something else, long story short, here's what fixed it for me...

How to remove package entirely.

The solution that ultimately resolved my issue of that stale shadow installation of the prisma package, was to go through these steps:
  1. uninstall the package globally: npm uninstall -g prisma (or more generic - npm uninstall -g <package>
  2. open the directory /usr/local/bin/
  3. locate the reference file prisma and delete it (I also had prisma2 - so I deleted that too)
  4. closed terminals and restarted my computer (this step may have been an overkill and may not be necessary).
You can ensure that the package is competely removed by running any command provided by the package, for example, I ran the above mentioned prisma -v.Once you've cleaned everything up, you can now if need be re-install a fresh, up-to-date version of the package.Hope this saves you some time 🙌🏼💜


Comments are currently disabled for this post.