← Back to all articles

Fastest Way to Delete Node Modules Like a Pro 😎

2 min read

Do you think is Black Hole or a Neutron Star is the heaviest object in the universe? No, you are wrong. It's the Node Modules πŸ˜‚. And when it comes to deleting them, It's the real pain 😒. But don't worry, I have a solution for you.

Method 1: Using npkill

npkill is a tool that helps you to find and remove node_modules folders from your computer. It works with macOS, Linux, and Windows.

  1. Install npkill globally using npm.
npm install -g npkill
  1. Go to the folder where you want to delete the node_modules folder and run npkill in your terminal.
npkill
  1. Select the folders you want to delete and press enter.
  2. Move between the listed folders with ↓ ↑, and use Space to confirm the deletion.
  3. Done! πŸŽ‰
  4. You can also use npkill with npx without installing it globally.
npx npkill

Method 2: Using rimraf

rimraf is a Node.js module that is used to delete files and folders. It is a cross-platform tool that runs on Windows, Linux, and macOS.

  1. Install rimraf globally using npm.
npm install -g rimraf
  1. Go to the folder where you want to delete the node_modules folder and run npkill in your terminal.
rimraf node_modules
  1. Done! πŸŽ‰
  2. You can also use rimraf with npx without installing it globally.
npx rimraf node_modules

Last updated on