Home >System Tutorial >MAC >How to Uninstall Node.js on Mac? How to Remove It?

How to Uninstall Node.js on Mac? How to Remove It?

William Shakespeare
William ShakespeareOriginal
2025-03-10 10:17:15638browse

Removing Node.js from your Mac: A Comprehensive Guide

Need to uninstall Node.js from your Mac to free up space or switch to a different development environment? This guide provides multiple methods, catering to different installation approaches. Node.js, a popular JavaScript runtime environment, is excellent for building scalable applications, but its removal can be tricky if you're unsure how it was installed.

Several methods exist for uninstalling Node.js, depending on your installation method: manual removal, Homebrew, Node Version Manager (NVM), or Terminal commands.

Manual Removal (Most Tedious):

This method requires meticulous attention to detail, as you'll manually delete individual files and folders.

  1. Open Finder, navigate to "Go" > "Go to Folder".
  2. Enter /usr/local/lib and click "Go".
  3. Locate and move any files containing "node" to the Trash.
  4. Repeat this process for the following directories: /usr/local/bin, /opt/local/bin/, /opt/local/lib/, /usr/local/lib/dtrace/, /opt/local/include/, /usr/local/include, /usr/local/share/doc/, /usr/local/share/man/man1/, /usr/local/share/systemtap/tapset/.

How to Uninstall Node.js on Mac? How to Remove It?

Homebrew Removal (Easiest):

If you used Homebrew, uninstalling is straightforward:

  1. Open Terminal and execute: brew uninstall --force node

How to Uninstall Node.js on Mac? How to Remove It?

NVM Removal (Simple):

Node Version Manager (NVM) simplifies the process.

  1. Open Terminal and use: nvm uninstall [version] (replace [version] with your Node.js version, e.g., nvm uninstall v18.16.0).

Determining Your Node.js Version:

  1. Download the macOS installer for Node.js.
  2. Run the installer and follow the on-screen instructions.
  3. Open Terminal and run node -v to display the installed version.

Terminal Command Removal:

This method uses Terminal commands for a complete uninstall.

  1. Open Terminal and run: sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
  2. To remove globally installed NPM packages: rm -rf ~/.npm

Conclusion:

Uninstalling Node.js can be complex. This guide offers various methods to suit different installation scenarios. For a thorough cleanup, consider using a dedicated uninstaller tool like MacKeeper's Smart Uninstaller to ensure all leftover files are removed. This will prevent potential conflicts and keep your system clean.

The above is the detailed content of How to Uninstall Node.js on Mac? How to Remove It?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn