Node.js ecosystem disk

How to Remove Old Node Versions in nvm and Free Up Disk Space (2026)

If you have been using Node.js on a Mac for a while, your nvm installation has quietly accumulated a separate copy of every Node version you ever installed. Knowing how to remove old node versions nvm keeps accumulating in ~/.nvm/versions/node/ is the first step toward reclaiming several gigabytes of wasted disk space. This guide walks through exactly how to audit what is there, uninstall the versions you no longer need, and tackle the surrounding build caches that nvm itself does not touch.

Why Old nvm Versions Eat So Much Space

Every time you run nvm install 20 or nvm install 22, nvm downloads a full Node.js binary distribution and extracts it into a self-contained directory under ~/.nvm/versions/node/. A single Node version typically consumes 150–300 MB depending on the release. If you have been swapping versions across projects, it is not unusual to find five to ten versions installed simultaneously, meaning anywhere from 1 GB to 3 GB sitting in one hidden folder.

nvm does not auto-prune old versions. Unless you actively uninstall them, they persist indefinitely — even across macOS upgrades from Ventura to Sonoma to Sequoia and beyond.

Where nvm Stores Everything on macOS

Before deleting anything, it helps to know exactly what lives where. The table below maps the directories nvm and Node tooling touch on a typical Mac in 2026.

Location What Is Stored Typical Size
~/.nvm/versions/node/ One subfolder per installed Node version (binaries, headers, npm) 150–300 MB per version
~/.npm/ npm's global cache (downloaded tarballs for every package ever installed) 500 MB – 3 GB
~/.nvm/alias/ nvm alias files (tiny, just text pointers) < 1 MB
~/Library/Caches/node-gyp/ node-gyp header downloads for building native addons 50–300 MB
node_modules/ in each project Per-project dependency trees 50 MB – 2 GB each

How to List and Audit Your Installed Node Versions

Open Terminal and run the following to see every version nvm knows about:

  1. List all installed versions and note which one is the current default:
    nvm ls
  2. Check which alias is set as your default so you do not accidentally remove it:
    nvm alias default
  3. See the raw disk footprint for each version:
    du -sh ~/.nvm/versions/node/*/
  4. Check what your active projects actually require by scanning their .nvmrc or .node-version files:
    find ~/Developer -maxdepth 3 -name '.nvmrc' -exec cat {} \; 2>/dev/null

After running these commands you will have a clear picture of which versions are candidates for removal and which are actively used.

How to Remove Old Node Versions with nvm Uninstall (Step-by-Step)

nvm provides a dedicated uninstall command that cleanly removes the version directory and any nvm-managed symlinks. Never manually delete folders from ~/.nvm/versions/node/ — let nvm do the bookkeeping.

Step 1 — Switch away from the version you want to remove

You cannot uninstall the currently active version. Switch to another first:

nvm use default

Step 2 — Uninstall a specific version

Replace the version number with the one you want to remove:

nvm uninstall 18.20.4

nvm will confirm the removal with output like Uninstalled node v18.20.4. The directory ~/.nvm/versions/node/v18.20.4/ is gone.

Step 3 — Batch-remove a range of old versions

If you have many old versions to clear out, a shell loop is efficient. The following example removes every v16.x and v18.x version in one pass (adjust the pattern to match your situation):

for v in $(nvm ls --no-colors | grep -oE 'v(16|18)\.[0-9]+\.[0-9]+'); do nvm uninstall "$v"; done

Step 4 — Verify the cleanup

Run nvm ls again to confirm only your intended versions remain, then spot-check disk use:

du -sh ~/.nvm/versions/node/

Clearing the npm Cache

Uninstalling Node versions does not touch npm's download cache at ~/.npm/. This cache can easily exceed 1 GB after months of package installs and is entirely safe to delete — npm rebuilds it on demand.

The correct way to clear it is through npm's own command, which verifies integrity before removing entries:

npm cache clean --force

If you want to inspect how large the cache is before committing:

du -sh ~/.npm

You can also wipe stale node-gyp headers, which accumulate in ~/Library/Caches/node-gyp/:

rm -rf ~/Library/Caches/node-gyp/

node-gyp re-downloads the appropriate headers the next time a native addon is compiled, so this is safe to delete at any time.

Cleaning Up node_modules Across Projects

The version directories in ~/.nvm/ are only part of the story. The real space hog on most developer Macs is the collection of node_modules folders scattered across every project directory. A single medium-sized Next.js project can have a node_modules tree exceeding 500 MB, and stale projects you have not touched in a year accumulate fast.

To find all node_modules directories under your home folder and list them by size, run:

find ~/Developer -type d -name 'node_modules' -prune -exec du -sh {} \; 2>/dev/null | sort -rh | head -20

For a deeper look at cleaning up project-level dependencies, see our guide on how to clean up node_modules on Mac — it covers safe deletion patterns, tools like npx npkill, and how to decide which projects to prune first.

Checking for Disk Pressure From Other Developer Tools

Node is often not the only culprit. A typical macOS development machine also accumulates large caches in:

  • ~/Library/Developer/Xcode/DerivedData/ — Xcode build products, often 5–30 GB
  • ~/.gradle/caches/ — Gradle dependency cache for Android and JVM projects
  • ~/.m2/repository/ — Maven local repository
  • ~/.cargo/registry/ and ~/.cargo/git/ — Rust crate sources and compiled artifacts
  • ~/Library/Caches/ — macOS application caches including CocoaPods, Homebrew, and more

A tool like Crumb can audit all of these locations at once and show exactly what is safe to remove before you delete anything, which is useful when you are not sure which caches belong to which tool.

If you are curious why macOS reports your storage as nearly full even after cleaning Node caches, this breakdown of what is actually taking up space on your Mac covers System Data, application support files, and other categories that often surprise developers.

Apple Silicon vs Intel: Any Differences to Know?

On Apple Silicon Macs (M1 through M4 and beyond in 2026), nvm installs arm64 binaries into the same ~/.nvm/versions/node/ path. If you ever ran nvm inside a Rosetta terminal session, you may have a mix of x64 and arm64 versions installed under the same version number structure — which can cause confusion. You can confirm the architecture of any installed version by running:

file ~/.nvm/versions/node/v20.18.0/bin/node

The output will say either Mach-O 64-bit executable arm64 or x86_64. If you find x86_64 versions you no longer need on an Apple Silicon Mac, they are the first candidates for removal — they run under Rosetta emulation and carry no performance benefit over their native arm64 counterparts.

Summary: The Cleanup Order That Works Best

Working through nvm disk bloat in this order gives you the most space in the least time and with the lowest risk:

  1. Run nvm ls and identify versions not referenced by any active project.
  2. Uninstall them one by one with nvm uninstall <version>.
  3. Clear the npm cache with npm cache clean --force.
  4. Delete stale node-gyp headers from ~/Library/Caches/node-gyp/.
  5. Find and remove orphaned node_modules folders in old project directories.
  6. Check broader developer caches (Xcode DerivedData, Gradle, Maven, Cargo) for additional savings.

After a full pass through these steps, most active Mac developers recover between 5 GB and 20 GB depending on how long the machine has been in use without maintenance.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Is it safe to uninstall old Node versions from nvm?
Yes. nvm uninstall only removes the specific version directory under ~/.nvm/versions/node/ and updates nvm's internal bookkeeping. Your global packages for other installed versions and your project node_modules folders are not affected. Just make sure you are not uninstalling the version currently aliased as default.
Where does nvm store Node versions on macOS?
nvm stores all installed Node versions under ~/.nvm/versions/node/, with one subdirectory per version (for example, ~/.nvm/versions/node/v22.14.0/). Each subdirectory contains the full Node binary, npm, and the standard library headers.
Will removing a Node version delete my global npm packages?
Yes — global packages are stored inside each version's directory, so uninstalling a version removes its associated globals. If you have globally installed tools like typescript or eslint under an old version, reinstall them under your current active version after cleanup.
How much disk space can I expect to recover?
Each Node version takes roughly 150–300 MB. On top of that, the npm cache at ~/.npm can hold 500 MB to several gigabytes. Cleaning five old Node versions plus the npm cache and orphaned node_modules folders typically recovers 5–15 GB on an active development Mac.
Does nvm uninstall also clear the npm cache?
No. nvm uninstall only removes the version directory itself. The npm download cache at ~/.npm is separate and must be cleared manually with npm cache clean --force. It is safe to delete and npm will rebuild it as needed.