Skip to main content

Explore your training options in 10 minutes

Getting Started with npm uninstall

Ryan Manchester - March 29, 2021

With any well designed software, there must be a way to not only install the software, but to uninstall it from your machine. Node Package Manager, or npm, offers a simple command to achieve this. Using the npm uninstall command will uninstall the specific package either from the current project’s package.json file, or globally.

Most of the time, packages will be installed locally inside the current project’s directory. This means in order to install and uninstall these packages, you must change directories in the command line until you’re in the desired project. Uninstalling a global package can be done from any directory in the command line with a –global flag.

How to Use npm uninstall

Calling the npm uninstall command from the project’s directory will uninstall the package and remove the package from the project’s package.json file. As a review, a package.json file is a file, written in JSON that keeps track of the project’s packages. Removing a package from the file using npm uninstall will cause the project to stop using that package in the scope of the project.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses

By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

Packages can locally or globally be installed. Most packages will be locally installed, meaning it is only available to the project in which it is installed. Globally installed packages are available to any project.

The npm package itself is an example of a global package. The command npm uninstall can be used in any project without having to install npm over again. Uninstalling packages can be done by calling the npm uninstall command followed by the package name.

npm uninstall <package name>

Using this syntax in the command line will uninstall the package specified. Doing so will remove that package from the package.json folder of the current project. If any other project uses this package, it will not be affected.

npm uninstall accepts three optional flags:

  1. –save or -S: removes the package from dependencies
  2. –save-dev or -D: removes from devDependencies
  3. –save-optional or -O: removes from optionalDependencies

Remember, these flags are optional. Most of the time, you’ll simply use the command followed by the package name alone.

To uninstall a global package, use the –global or –g flag. Let’s say that you’ve been using React for years and want to use a different frontend library. To uninstall the create-react-app package from your computer completely, you’d use this command:

npm uninstall create-react-app --global


npm uninstall create-react-app -g

This will uninstall the package and remove anything npm installed on its behalf.


Using the npm uninstall command in your CLI is a safe and quick way to remove the package and anything else npm installed related to it. It provides a way to clean up any unused packages either inside a current project or from your entire computer. When uninstalling a package from your computer, don’t forget to use the –global or –g flag.

Including optional flags at the end of the uninstall command will remove the package only from those specific dependency files. This provides a little more control over uninstalling when needed. In general, using the simple syntax of npm uninstall <package name> will be the most common use case.

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

Ryan Manchester

About the author: Ryan is a technical writer at Career Karma, where he covers programming languages, technology, and web development. The Texas native earned his Bachelor's of Music Composition from the University of North Texas. Ryan is currently pursuing further education in web development, aiming to graduate from Flatiron School with a certification in full stack web development. Since joining the Career Karma team in November 2020, Ryan has used his expertise to cover topics like React and Ruby on Rails.

Skip to main content