How to Uninstall npm packages
Table of Contents
Sometimes you no longer need an NPM package in your project. In those cases, you'll want to uninstall them to get rid of the dependency.
In this post, we'll learn how to uninstall NPM packages.
How to uninstall NPM packages
To uninstall an NPM package, you can use the npm uninstall
command, followed by the package name.
BASHnpm uninstall <package>
For example:
BASHnpm uninstall lodash
This command will uninstall the package by removing it from your node_modules
directory and removing the package from your package.json
file. It will also update the package-lock.json
file to reflect the changes.
If you're using yarn, you can use the yarn remove
command instead.
BASHyarn remove <package>
BASHyarn remove lodash
If your package was installed globally, you will have to uninstall it globally as well. This is done by using the npm uninstall -g
command.
BASHnpm uninstall -g <package>
Because this is a global operation, you don't need to be in the root of your project to run this command.
Conclusion
In this post, we learned how to uninstall NPM packages using NPM and yarn.
We also learned how to uninstall packages globally by using the --global
flag.
Hopefully, this has been helpful to you. Thanks for reading!
- Getting Started with Solid
- How to deploy a PHP app using Docker
- How to Scrape the Web using Node.js and Puppeteer
- Build a Real-Time Chat App with Node, Express, and Socket.io
- Getting User Location using JavaScript's Geolocation API
- Getting Started with Moment.js
- Creating a Twitter bot with Node.js
- Using Push.js to Display Web Browser Notifications
- Getting Started with React
- Getting Started with Vuex: Managing State in Vue
- Setting Up a Local Web Server using Node.js
- How To Create a Modal Popup Box with CSS and JavaScript