Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right way uninstalling the NPM packages (Npm Uninstall vs Edit package.json)

I have to remove several libraries from the project. Currently worried about what if I remove a library, which is dependency of any other library.

Which approach can safely remove the libraries ?

I see I have two choices:

  1. Edit package.json manually. Remove library entries... Delete node_modules folder and do npm install.

  2. do npm uninstall --save for each package.

What are difference between two, especially when I want to take one step at a time. Without breaking any peer dependencies

like image 707
Abhijeet Avatar asked Dec 28 '25 12:12

Abhijeet


1 Answers

There is no difference at all

npm un package_name package_name ....

will uninstalls a package, completely removing everything npm installed on its behalf

It also removes the package from the dependencies, devDependencies, optionalDependencies, and peerDependencies objects in your package.json and update package-lock.json file also

--save or -S will tell npm to remove the package from your package.json and package-lock.json files. This is the default, you don't have to use it.

--no-save is opposite to --save will tell npm not to remove but uninstall

like image 60
Yuvaraj M Avatar answered Dec 31 '25 00:12

Yuvaraj M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!