最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Right way uninstalling the NPM packages (Npm Uninstall vs Edit package.json) - Stack Overflow

programmeradmin3浏览0评论

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

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

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 1
  • Does this answer your question? How can I uninstall npm modules in Node.js? – Jordy Commented Nov 1, 2023 at 8:51
Add a comment  | 

1 Answer 1

Reset to default 23

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

发布评论

评论列表(0)

  1. 暂无评论