Home  >  Article  >  Web Front-end  >  A brief analysis of how to use npkill to quickly find and delete node_modules

A brief analysis of how to use npkill to quickly find and delete node_modules

青灯夜游
青灯夜游forward
2021-11-15 10:11:232576browse

This article will introduce to you how to use npkill to quickly find node_modules on the computer/server and quickly delete it. I hope it will be helpful to everyone!

A brief analysis of how to use npkill to quickly find and delete node_modules

Question: How to quickly find node_modules on the computer/server and delete them quickly? (Recommend npkill)

Original intention:

Node.js When using npm to install dependent modules for projects or front-end projects, always create a new node_modules in the project root directory, and in A series of packages are installed inside. Generally speaking, it takes up a lot of space. As there are more and more projects and more and more dependent modules, the space will become larger and larger. At some point, this will cause some problems. If you have an Alibaba Cloud server and the cloud disk is very small, and it is not possible or difficult to add a cloud disk, when the disk is tight, it would be a good idea to quickly know the size occupied by all node_modules and delete them. solutions to improve efficiency. [Recommended learning: "nodejs Tutorial"]

npkill

npkill is a Node.js package that can help us quickly list the files in the system Each node_modules folder, and the amount of space they occupy. You can then select specific node_modules folders to delete.

Usage

npm global installation

$ npm -g i npkill

pnpm global installation:

$ pnpm -g i npkill(更推荐)

A brief analysis of how to use npkill to quickly find and delete node_modules

##Pictures from

npkill's github README, the operation process is as shown in the picture above: npkill When searching, the upper right corner will display searching, indicating that the search is in progress, and the search is completed. It will be displayed as search completed.

Follow the prompts and hit the space bar to delete, one at a time. For more functions, please check the official address document:

https://github.com/voidcosmos/npkill#readme

Tips:

For those installed using npm Dependency, this is a good solution, but if you use pnpm to install it, you don’t need to consider the space occupied by node_modules at all, because pnpm does not install the module in every node_modules, but in the form of a link, and finally links to the specific Directory address, for pnpm's installation dependency principle, it is recommended to read an article by a big guy (

#In-depth thinking about modern package managers - why do I recommend pnpm instead of npm/yarn now? )

Due to some historical issues with npm and its current situation, I hope to use pnpm more often than npm.

For more programming-related knowledge, please visit:

Introduction to Programming ! !

The above is the detailed content of A brief analysis of how to use npkill to quickly find and delete node_modules. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete