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:
Edit package.json manually. Remove library entries... Delete node_modules folder and do npm install.
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
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:
Edit package.json manually. Remove library entries... Delete node_modules folder and do npm install.
do npm uninstall --save for each package.
Share Improve this question edited Nov 1, 2023 at 5:05 Abhijeet asked Oct 31, 2023 at 11:31 AbhijeetAbhijeet 13.9k29 gold badges104 silver badges189 bronze badges 1What are difference between two, especially when I want to take one step at a time. Without breaking any peer dependencies
- Does this answer your question? How can I uninstall npm modules in Node.js? – Jordy Commented Nov 1, 2023 at 8:51
1 Answer
Reset to default 23There 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