Do you want to become a better fullstack software engineer?
<->
How to Remove a Package From Your Javascript Project Using NPM

We will discuss how to remove a package from your JavaScript project using NPM. Starting with the main command, then with the alternative ones.

Let's get started!

Uninstall NPM package and all its dependencies

To remove a package from your project using npm, you can use the uninstall command (npm uninstall [package_name]). This will remove the package and all of its dependencies from your project. Here's an example:

$ npm uninstall tailwindcss

This will uninstall the tailwindcss package and all of its dependencies from your project. Keep in mind that this command will remove the package, which means that you should remove all usages of this library in your code. Otherwise, your code will not compile anymore.

If you want to discover more, here is another article about how to update a package using NPM.

Remove NPM package and keep its dependencies

If you want to remove a package but keep its dependencies, you can use the prune command (npm prune [package_name]). This will remove the package from your project, but won't touch any of its dependencies. Here's an example:

$ npm prune tailwindcss

Uninstall a global NPM package

If you want to delete a global NPM package and all of its dependencies, you can use the command uninstall with the -g flag (npm uninstall -g [package_name]). This will delete the package, all of its dependencies from your project, as well as its global version on your computer. Here's an example:

$ npm uninstall -g tailwindcss

➡️ I regularly deliver content about web development, personal growth as a developer, and my journey as an aspiring digital nomad and remote software engineer. If you don't want to miss them, I invite you to follow me on Twitter. 🚀

Learn to code with simple and concrete examples.

English / Français