Is it safe to delete node_modules?

<project>/node_modules · Safe to delete

What it is

Packages installed for one JavaScript or TypeScript project.

Can you delete it?

Yes, it is rebuilt automatically. npm install (or yarn, pnpm, bun) rebuilds it from package.json and the lock file. Old projects can hold gigabytes.

How to clean it safely

  1. Check the project has no uncommitted work you care about (git status).
  2. Delete node_modules, then run npm install when you need the project again.

Questions

Is it safe to delete /node_modules?

Yes, it is rebuilt automatically. npm install (or yarn, pnpm, bun) rebuilds it from package.json and the lock file. Old projects can hold gigabytes.

Let the raccoon do it, safely

Junk Raccoon finds this clutter for you, shows every file first, and keeps a one-click way back. Free beta for Mac.

Download for Mac