TechEarl

How to Uninstall Node.js (Every Install Method)

How to uninstall Node.js cleanly on Linux, macOS, and Windows: version managers (nvm, fnm, Volta, n), the official installer, apt/dnf/brew/winget/choco, Docker, plus the leftover npm/cache/PATH files everyone forgets to delete.

Ishan Karunaratne⏱️ 14 min readUpdated
Share thisCopied
How to uninstall Node.js completely on Linux, macOS, and Windows, including removing leftover npm, npx, and global package directories

Uninstalling Node.js is rarely the one-step "drag to trash" people expect, because the right command depends entirely on how Node was installed: a version manager (nvm, fnm, Volta, n), the official nodejs.org installer, your OS package manager (apt, dnf, brew, winget, choco), or a Docker image you just stop using. Each path removes the node binary differently, and almost none of them clean up the leftovers: the global npm package directory, the npm/npx caches, and the PATH lines in your shell rc file. I have torn Node off machines to fix a wedged install, to clear out a botched permission setup, and to hand a laptop back clean. The binary always goes easily; the orphaned ~/.npm cache and the dead PATH export that prints node: command not found on every new shell are what bite later. Below is the full removal reference for every realistic install route in 2026, including the leftover-files checklist that most guides skip.

How do I uninstall Node.js?

To uninstall Node.js, first find out how it was installed by running which node (or where node on Windows). If the path is under ~/.nvm, remove that version with nvm uninstall <version> (or delete ~/.nvm entirely to remove nvm and every Node it manages). For fnm, fnm uninstall <version>; for Volta, delete ~/.volta; for n, sudo n rm <version> then sudo npm rm -g n. If you installed from nodejs.org, on macOS remove /usr/local/bin/node, /usr/local/bin/npm, and the node files under /usr/local/lib and /usr/local/include; on Windows use "Apps and features" (or winget uninstall OpenJS.NodeJS). On Linux without a manager, sudo apt-get remove --purge nodejs (Debian/Ubuntu) or sudo dnf remove nodejs (RHEL/Fedora). On macOS Homebrew, brew uninstall node. After removing the binary, delete the leftovers: ~/.npm (cache), ~/.node-gyp, the global package dir (~/.npm-global or /usr/local/lib/node_modules), and any nvm/fnm/volta lines in ~/.bashrc or ~/.zshrc. Open a new terminal and confirm with which node returning nothing.

Jump to:

Pre-flight: find out how Node was installed

Before deleting anything, capture what you have. The single most useful command is which node, because the path tells you which removal route to take:

bash
node --version    # e.g. v22.11.0
which node        # the install path is the whole answer
npm --version     # confirm npm came along with it

Read the path it prints:

which node printsInstall typeRemoval route
~/.nvm/versions/node/...nvmnvm uninstall or delete ~/.nvm
~/.fnm/... or ~/Library/.../fnm/...fnmfnm uninstall or delete the fnm dir
~/.volta/bin/nodeVoltadelete ~/.volta
/usr/local/bin/node (macOS, no brew)nodejs.org installer or nmanual file removal
/opt/homebrew/bin/node or /usr/local/... (brew)Homebrewbrew uninstall node
/usr/bin/node (Linux)apt / dnf / NodeSourceapt remove / dnf remove
C:\Program Files\nodejs\node.exeWindows .msi / wingetApps and features

On Windows, run where node in PowerShell or cmd to get the same answer. If which node prints two paths, you have more than one install fighting over PATH; note both, because you will want to remove the dead one (see Troubleshooting).

If which node prints nothing, Node is already off your PATH and you may only have leftovers to clean up (jump to the leftover-files checklist).

Method by install type (quick table)

Install typeUninstall commandRemoves leftovers?
nvmnvm uninstall <version>, or rm -rf ~/.nvm for all of itNo, you remove the rc-file line by hand
fnmfnm uninstall <version>, or delete the fnm dirNo, remove the fnm env rc line by hand
Voltarm -rf ~/.voltaNo, remove the VOLTA_HOME/PATH rc lines by hand
nsudo n rm <version> then sudo npm rm -g nPartly, /usr/local/n may linger
nodejs.org (macOS)manual rm of the installed files (script below)No
nodejs.org (Windows)Apps and features, or winget uninstallNo, %AppData%\npm lingers
apt / dnfsudo apt-get remove --purge nodejs / sudo dnf remove nodejs--purge removes config, not ~/.npm
Homebrewbrew uninstall nodeMostly, ~/.npm cache lingers
winget / chocowinget uninstall OpenJS.NodeJS / choco uninstall nodejsNo
Dockerdocker rmi node:<tag>N/A, image is self-contained

The recurring theme: removing the binary is one command, but no package manager or version manager cleans up the per-user npm state. That is the leftover-files checklist below.

Uninstall a version manager (nvm, fnm, Volta, n)

If a version manager owns your Node, let it do the removal. You can either uninstall a single Node version (keeping the manager) or remove the manager entirely.

nvm. Remove one version, or wipe the whole thing:

bash
nvm ls                          # list installed versions
nvm uninstall 18.19.0           # remove one version
nvm uninstall --lts             # remove the current LTS install

# Remove nvm itself and every Node it manages:
rm -rf "$NVM_DIR"               # usually ~/.nvm
rm -rf ~/.nvm                   # if $NVM_DIR is unset

Then delete the nvm block from your shell rc file (~/.bashrc, ~/.zshrc, or ~/.profile). nvm's installer appends something like:

bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Remove those lines, save, and open a new terminal. nvm does not have a self-uninstall command; deleting the directory plus the rc lines is the documented way.

fnm. Same pattern:

bash
fnm list                        # installed versions
fnm uninstall 18.19.0           # remove one version

# Remove fnm itself: delete its binary and data dir, then the rc hook
rm -rf ~/.local/share/fnm ~/.fnm

If you installed fnm via Homebrew use brew uninstall fnm; via winget, winget uninstall Schniz.fnm. Remove the eval "$(fnm env --use-on-cd)" line from your rc file (or the PowerShell $PROFILE equivalent).

Volta. Volta has no uninstall subcommand; you delete its directory:

bash
rm -rf ~/.volta

Then remove the two lines Volta's installer added to your rc file:

bash
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"

Because Volta also shims npm/yarn/pnpm, deleting ~/.volta takes those shims with it. Any Node version pinned in a project's package.json "volta" key is just metadata; it does nothing once Volta is gone.

n. n installs into /usr/local and is itself an npm global:

bash
sudo n rm 18.19.0               # remove a managed version
sudo npm rm -g n                # remove the n tool

# n leaves the version cache behind; clear it:
sudo rm -rf /usr/local/n

Because n symlinks the active Node into /usr/local/bin/node, also check that /usr/local/bin/node, npm, and npx are gone after the above. If they still point at a deleted target, sudo rm them.

Uninstall the nodejs.org installer on macOS

The macOS .pkg from nodejs.org does not ship an uninstaller. It drops files into /usr/local, and you remove them by hand. This is the canonical command set (it is what the old pkgutil receipts list):

bash
sudo rm -rf /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/npx
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/include/node
sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/share/doc/node

# Forget the installer receipts so macOS no longer thinks Node is present:
sudo pkgutil --forget org.nodejs.node.pkg 2>/dev/null
sudo pkgutil --forget org.nodejs.pkg 2>/dev/null

pkgutil --pkgs | grep -i node lists the exact receipt IDs on your machine if those two do not match; forget whatever it prints. After this, the per-user leftovers (~/.npm, ~/.node-gyp) are still there; see the leftover-files checklist.

If node lives under /opt/homebrew (Apple Silicon Homebrew) rather than /usr/local, it is a brew install, not the .pkg. Use brew uninstall node instead of the manual removal above.

Uninstall on Windows

The nodejs.org .msi and the winget package both register a proper uninstaller, so use it; do not hand-delete C:\Program Files\nodejs.

GUI route: Settings, then "Apps", then "Installed apps", find Node.js, then "Uninstall".

Command line:

powershell
# winget (works whether you installed via winget or the .msi)
winget uninstall OpenJS.NodeJS
winget uninstall OpenJS.NodeJS.LTS

# Chocolatey
choco uninstall nodejs
choco uninstall nodejs-lts

The Windows uninstaller removes C:\Program Files\nodejs and its PATH entry, but it leaves the per-user npm state behind. After uninstalling, delete these by hand (close all terminals first):

powershell
Remove-Item -Recurse -Force "$env:AppData\npm"
Remove-Item -Recurse -Force "$env:AppData\npm-cache"
Remove-Item -Recurse -Force "$env:LocalAppData\npm-cache"
Remove-Item -Recurse -Force "$env:UserProfile\.node-gyp"

Then check the user and system PATH in "Edit environment variables" and remove any stale ...\nodejs or ...\AppData\Roaming\npm entries the uninstaller missed. For nvm-windows, use its own uninstaller from Apps and features rather than deleting the install directory, because it manages a symlink that the uninstaller cleans up properly.

Uninstall via OS package managers

If Node came from your distro's repo or from NodeSource, the package manager removes it.

Debian / Ubuntu (apt):

bash
sudo apt-get remove nodejs            # remove the package
sudo apt-get remove --purge nodejs    # also remove its config files
sudo apt-get autoremove               # drop now-unused dependencies

# If you added the NodeSource repo, remove its source list and key too:
sudo rm -f /etc/apt/sources.list.d/nodesource.list
sudo rm -f /etc/apt/keyrings/nodesource.gpg
sudo apt-get update

RHEL / Fedora / Rocky / Alma (dnf):

bash
sudo dnf remove nodejs
sudo rm -f /etc/yum.repos.d/nodesource*.repo   # if NodeSource was used

macOS Homebrew:

bash
brew uninstall node            # or: brew uninstall node@22
brew uninstall --force node    # if multiple versions are linked
brew cleanup                   # remove old downloaded bottles

brew uninstall node removes the formula and its symlinks in /opt/homebrew/bin (or /usr/local/bin on Intel), but the ~/.npm cache in your home directory is not brew-managed and survives. Clean it manually (next section).

A subtle apt gotcha: on older Ubuntu the distro ships both nodejs and a separate npm package. Run dpkg -l | grep -E 'nodejs|npm' and remove both if present, otherwise npm lingers as an orphan pointing at a deleted Node.

Remove a Docker Node image

There is nothing to "uninstall" inside a container; you remove the image and any containers based on it from the host.

bash
docker ps -a --filter ancestor=node:22-alpine    # find containers using it
docker rm <container-id>                          # remove stopped containers
docker rmi node:22-alpine                         # remove the image

# Sweep everything Node-image related at once:
docker images "node" -q | xargs -r docker rmi
docker image prune                                # drop dangling layers

Because the Node binary lives entirely inside the image layers, removing the image takes Node with it; there are no host-side leftovers (no ~/.npm on the host unless you bind-mounted it). The only thing to update afterward is the FROM node:... line in any Dockerfile you do not want to rebuild against.

The leftover-files checklist (the part everyone skips)

Removing the binary leaves three categories of state behind: the npm caches, the global package directory, and the PATH/shell-init lines. On a machine you are reusing, these are harmless clutter; on a machine you are handing over or trying to fix, they are the source of "I uninstalled Node but npm still half-works" confusion.

bash
# npm + npx caches and config
rm -rf ~/.npm                  # the npm cache
rm -rf ~/.npmrc                # only if you want config gone too
rm -rf ~/.node-gyp             # cached node headers for native builds
rm -rf ~/.node_repl_history

# Global packages installed to a user prefix
rm -rf ~/.npm-global           # if you set prefix=~/.npm-global
# (system prefix globals live in /usr/local/lib/node_modules, removed above)

# corepack / yarn / pnpm shims, if you used them
rm -rf ~/.cache/node ~/.local/share/pnpm ~/.yarn

On Windows the equivalents are %AppData%\npm, %AppData%\npm-cache, %LocalAppData%\npm-cache, and %UserProfile%\.npmrc (shown in the Windows section above).

Then clean your shell rc file. Open ~/.bashrc, ~/.zshrc, or ~/.profile and delete any of these blocks that a version manager added:

  • export NVM_DIR=... plus the two nvm.sh / bash_completion source lines (nvm)
  • eval "$(fnm env --use-on-cd)" (fnm)
  • export VOLTA_HOME=... and the PATH line that prepends $VOLTA_HOME/bin (Volta)
  • any manual export PATH="...node...:$PATH" you added by hand

A stale PATH export is the usual cause of node: command not found printed on every new shell after an "uninstall": the binary is gone but the rc file still tries to add its directory to PATH. Reload with source ~/.zshrc or just open a fresh terminal.

Verify Node is fully gone

bash
which node || echo "node: gone"
which npm  || echo "npm: gone"
which npx  || echo "npx: gone"
command -v node >/dev/null && echo "still on PATH" || echo "clean"

All four should report gone/clean in a new terminal (a current shell may have a cached path; hash -r clears bash/zsh's command cache, or just open a new window). On Windows, where node should print "Could not find files for the given pattern(s)".

If you only meant to switch versions rather than remove Node entirely, you do not need any of this; see how to update your Node.js version for the in-place upgrade path instead.

Troubleshooting

node: command not found on every new shell after uninstalling. A version manager's init line is still in your rc file pointing at a directory that no longer exists. Remove the NVM_DIR / fnm env / VOLTA_HOME block from ~/.bashrc or ~/.zshrc (see the checklist above) and open a fresh terminal.

npm still works after I removed node. You removed one install but another is still on PATH, or npm is symlinked to a global prefix that survived. Run which -a node npm (the -a shows every match) and remove the install you missed. A common case: you deleted the nvm Node but a /usr/local/bin/node from an old .pkg install is still there.

EACCES or "permission denied" deleting /usr/local/lib/node_modules. Those files are root-owned from a sudo-based install. Prefix the removal with sudo: sudo rm -rf /usr/local/lib/node_modules. Double-check the path before running it.

brew uninstall node says "node is required by ...". Another formula depends on Node. Either remove that formula first, or pass brew uninstall --ignore-dependencies node if you are sure you want Node gone regardless.

which node still prints a path after Homebrew uninstall. Your shell cached the old location. Run hash -r (bash/zsh) to clear the command cache, then re-check.

Two version managers were installed at once. Symptom: which -a node shows paths under both ~/.nvm and ~/.volta. Pick one to keep (or remove both), delete the other's directory and its rc-file init lines, and reload the shell. Mixing managers is the top cause of "uninstall did not take" reports.

See also

FAQ

Sources

Authoritative references this article was fact-checked against.

TagsNode.jsJavaScriptnvmfnmVoltaVersion ManagementCLIHomebrewWindowsDevOps

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Tech Architect · Software Engineer · AI/DevOps

Tech architect and software engineer with 20+ years building software, Linux systems, and DevOps infrastructure, and lately working AI into the stack. Currently Chief Technology Officer at a healthcare tech startup, which is where most of these field notes come from.

Keep reading

Related posts

How to SSH into an AWS EC2 Instance

Connect to an EC2 instance four ways: plain SSH with a key pair, EC2 Instance Connect, Session Manager, and EC2 Instance Connect Endpoint. Default usernames, security group rules, and the troubleshooting matrix that fixes Permission denied and Connection timed out.