OptiClear

Developer Tools

Clear Node.js / npm Cache on Mac

Clearing the Node.js / npm cache is safe, because npm refills it the next time you install something. You can do it with two commands in Terminal, and your projects and global packages stay as they are.

Last updated: 3 min read

Clear the Node.js / npm cache without guessing

Node.js / npm data usually takes 500 MB – 20 GB on a Mac. The free scan shows the exact size on your Mac before you change anything.

Scan your Mac free

Free scan · No account · Nothing is deleted without your OK · Moves to the Trash first · macOS 14+

Application
Node.js / npm
Typical data size
500 MB – 20 GB
Category
Developer Tools
File Location
~/.npm

Clear it from inside Node.js / npm first

The safest way is the option built into the app: npm cache verify checks and trims the cache and npm cache clean --force empties it; neither touches node_modules in your projects or global packages.

Node.js / npm cache folders you can clear

These folders are rebuilt automatically, so removing them does not touch your own files.

Locations checked on a Mac with Node.js / npm installed.

What the Node.js / npm cache holds

Specific to Node.js / npm

The cache lives in the ~/.npm folder and holds downloaded packages, packages fetched by npx, and debug logs from npm commands. Everything in it is a copy that npm can download again, so none of it is your own work. Clearing it helps when that folder has grown to several gigabytes, or when installs fail with integrity or EINTEGRITY errors. The largest space user is usually the node_modules folder inside each project, which the cache does not touch. Global packages and your npm sign-in token are stored elsewhere and are not part of the cache.

What happens after you clear Node.js / npm cache

Run npm cache verify first to check and trim the cache, or npm cache clean --force to empty it completely. Neither command touches node_modules in your projects or your global packages. npm rebuilds the cache automatically, so your next install takes longer while it downloads packages again. You do not need to sign in again, because an npm account is only needed to publish packages and your token stays in place.

0 of 4 done

Account and sync
An npm account is only needed to publish packages; the token is stored in ~/.npmrc.

Try it without risk

  1. Download and scan for freeSee every Node.js / npm file and its size. No account needed.
  2. Clean free for 7 daysStart the 7-day free trial of the yearly plan inside the app.
  3. Keep it or cancelCancel in your App Store settings at least 24 hours before the trial ends and you won't be charged.
Download free and scan

After the free trial, Pro costs $39.99 per year in your country's App Store; cancel any time.

Frequently asked questions

Yes. Folders marked “Yes, rebuilt automatically” are rebuilt automatically; removing them only makes the next start slower.
Do I need to sign in to npm again after clearing the cache?
No. An npm account is only needed to publish packages, and your token is kept, so ordinary installs keep working.
Why is my disk still full after clearing the cache?
Each project keeps its own node_modules folder, and clearing the cache does not change those. Check those folders project by project, since they are usually the bigger share of the space.

Related cleanup guides