Unlock your Web Development skills with free daily content! 🚀

Home » Blog » How to Remove a Package From Your Javascript Project Using NPM

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

Thanks for reading. Let’s connect!

➡️ I help you grow into Web Development, and I share my journey as a Nomad Software Engineer. Join me on Twitter for more. 🚀🎒

Gaël Thomas

Unlock your Web Development skills! 🚀 I'm a Remote Software Engineer sharing educational content. Let's learn & grow together! 📚 DMs are open, let's connect (on Twitter) 🤝

Post navigation