NPM uninstall

Since working on my second MERN project I’ve been trying a whole bunch of libraries to upload files, to validate forms, to create SEO tags, etc; which by the end of the day I might not end up using them because I decided to work with a different one, etc. This post will be short and its going to be about how to uninstall dependencies/packages/libraries/etc.

Let’s put it this way. To find what packages you have installed in your application, a document with the name of package.json will contain an object similar to this one:

"dependencies": {
    "bcryptjs": "^2.4.3",
    "config": "^3.1.0",
    "express": "^4.16.4",
    "express-fileupload": "^1.1.5",
    "express-validator": "^5.3.1",
    "gravatar": "^1.8.0",
    "jsonwebtoken": "^8.5.1",
    "jw-paginate": "^1.0.4",
    "mongoose": "^5.5.8",
    "request": "^2.88.0"
  },

So far those, are the dependencies that I have left in my project after getting rid off hundreds of them, I mean hundreds!. Some of you might recognize them because these are mainly used for the server-side logic any app might have.

Now going back to the topic, the command to use is very simple, npm uninstall <PACKAGE_NAME> --save. Here are several ways you can use it:

  • npm uninstall <name> removes the module from node_modules, but not package.json
  • npm uninstall <name> --save also removes it from dependencies in package.json
  • npm uninstall <name> --save-dev also removes it from devDependencies in package.json
  • npm -g uninstall <name> --save removes it globally

Damn easy, right?!

Reference: https://stackoverflow.com/questions/13066532/how-to-uninstall-npm-modules-in-node-js

Don’t forget to share this article with your friends if you found it useful. Also don’t forget to comment what you think about!.

Bye-Bye 🙂

Leave a Reply

Back to Top