You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已卸载Node但node -v仍显示版本,如何彻底移除及版本切换问题

Hey there! Let's break down your two Node.js issues step by step—they’re super common, so I’ve got straightforward fixes for you.

1. How to Completely Remove Node.js (and Fix node -v Still Showing a Version)

If you’ve uninstalled Node but node -v still spits out a version number, it means leftover files are lingering or your system’s PATH still points to an old Node installation. Here’s how to clean it up fully (focused on macOS since you mentioned Homebrew, with quick notes for other systems):

  • First, confirm you’ve uninstalled via Homebrew
    If you used Homebrew to install Node, run these commands to ensure it’s fully removed:

    brew uninstall node
    brew cleanup
    

    If you used version managers like nvm or n before, be sure to uninstall those specific versions too (e.g., n uninstall 10.0 or nvm uninstall 10.0).

  • Delete leftover Node files and folders
    Run this command to wipe common residual files:

    sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
    

    Also manually check and delete these directories if they exist:

    • /usr/local/lib/node
    • /usr/local/lib/node_modules
    • /usr/local/include/node
    • ~/Library/Application Support/npm
    • ~/Library/Caches/npm
  • Update your shell’s PATH
    Open your shell config file (either ~/.bash_profile, ~/.zshrc, or ~/.profile depending on which shell you use) and delete any lines that add Node-related paths to PATH. Then reload the config:

    source ~/.zshrc  # Swap with ~/.bash_profile if you use Bash
    
  • Verify the cleanup
    Close and reopen your terminal, then run node -v and which node. If both return "command not found", you’ve successfully removed Node.

Quick notes for other systems:

  • Windows: Uninstall Node via Control Panel, delete the C:\Program Files\nodejs folder, and remove Node entries from your system PATH.
  • Linux: Use your package manager (e.g., sudo apt purge nodejs npm) then delete leftover files in /usr/local/lib/node or ~/.npm.
2. Fixing node -v Still Showing 10.0 After brew uninstall node

First, let’s diagnose the root cause: When you run brew uninstall node, it removes the Homebrew-installed Node, but your shell might be pointing to a different Node installation (like one from the official installer, nvm, or even a system-preloaded version).

To confirm where the active Node is coming from, run:

which node

This will show the file path of the Node executable your shell is using. If it’s not /usr/local/bin/node (Homebrew’s default path), that’s your culprit—you have another Node installation elsewhere.

Now, about the solution you’re referencing: Even without seeing the link, I can tell you that most valid fixes for this scenario fall into these categories, which are all reliable:

  • Remove the non-Homebrew Node installation: If which node points to a path like /usr/bin/node (system Node) or a nvm-managed location, uninstall that version directly. For official installer leftovers, use the full cleanup steps from the first section. For nvm, run nvm use system then nvm uninstall 10.0.
  • Adjust PATH priority: If the old Node’s path appears before Homebrew’s /usr/local/bin in your PATH, your shell will pick the old version first. Edit your shell config file to move /usr/local/bin to the front of the PATH list.
  • Clear shell cache: Sometimes your shell caches executable locations. Run hash -r to clear this cache, then test node -v again.

If the solution you found includes any of these steps, it’s absolutely viable. The key is first pinpointing where the old Node lives with which node, then targeting that installation or adjusting your PATH accordingly.

Once the old version is gone, installing Node 8.9 is straightforward. I’d recommend using nvm (it makes version switching way less headache-prone):

# Install nvm first if you don't have it
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# Then install and use Node 8.9
nvm install 8.9
nvm use 8.9

Or if you prefer Homebrew:

brew install node@8.9
brew link --force node@8.9

内容的提问来源于stack exchange,提问作者Neer Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:21:23