How to Uninstall Node.js from Mac: A Comprehensive Guide

Written by: Editor In Chief
Published on:

If you’re wondering how to uninstall Node on Mac, you’ve come to the right place. Uninstalling Node.js might seem daunting, but with the right instructions, it can be a breeze. In this article, we’ll walk you through the step-by-step process to ensure you remove Node.js completely and efficiently from your macOS system.

Why Would You Want to Uninstall Node.js?

Before we discuss how to uninstall Node on Mac, let’s explore why you might need to do this:

  • Version Compatibility Issues: You may need to uninstall and reinstall Node.js to upgrade or downgrade to a specific version.

  • System Cleanup: If Node.js is outdated or no longer needed, removing it can free up system resources.

  • Troubleshooting: Sometimes Node.js installations can lead to conflicts or errors that could necessitate a complete removal.

What Are the Steps to Uninstall Node on Mac?

To effectively uninstall Node.js from your Mac, follow these straightforward steps:

Step 1: Verify the Installation of Node.js

Before removing Node.js, you should confirm its current status.

  • Open Terminal: Use Spotlight (Cmd + Space) and type “Terminal.” Press Enter to open it.

  • Check for Node Installation: Type the following command:

bash
node -v

  • Verify NPM Installation: Similarly, check for NPM (Node Package Manager) by typing:

bash
npm -v

These commands will display the installed versions of Node.js and NPM, confirming their presence on your system.

Step 2: Use Homebrew to Uninstall Node.js (if applicable)

If you installed Node.js via Homebrew, this method should work effectively.

  • Open Terminal: As mentioned before.

  • Uninstall Node.js: Type the following command:

bash
brew uninstall node

This command removes Node.js from your system if it was installed via Homebrew.

Step 3: Remove Node.js Manually

If you didn’t use Homebrew to install Node.js, you can uninstall it manually.

  1. Open Terminal: Launch Terminal once more if you haven’t already.

  2. Remove Node and NPM: Execute the following commands to remove Node.js and NPM files across various directories. You can enter these commands one at a time:

    bash
    sudo rm -rf /usr/local/lib/node_modules
    sudo rm -rf /usr/local/include/node
    sudo rm -rf /usr/local/bin/node
    sudo rm -rf /usr/local/bin/npm

  3. Check for Other Node.js Files: You might want to check if there are additional directories or files related to Node.js. Run:

    bash
    sudo rm -rf ~/.npm
    sudo rm -rf ~/.node-gyp
    sudo rm -rf ~/.nvm

Step 4: Verify Removal

After executing the commands, it’s essential to confirm that Node.js has been successfully uninstalled.

  • Check Node Version: Run:

bash
node -v

You should see an error message indicating that the command is not found.

  • Check NPM Version: Similarly, run:

bash
npm -v

You should receive an error message confirming that NPM is no longer present.

Are There Any Residual Files Left After Uninstallation?

After you’ve completed the uninstallation process, it’s a good practice to check for any leftover files or dependencies.

  1. Use Finder: Navigate to common directories where Node.js might leave residual files:
  • /usr/local/lib
  • /lib/node_modules
  • /usr/local/include
  • Hidden directories in your home folder like .npm, .node-gyp, and .nvm.
  1. Use Spotlight: You can also search for “node” and “npm” in Spotlight (Cmd + Space) to find any leftover files.

What Should You Do After Uninstalling Node.js?

Once you successfully learn how to uninstall Node on Mac, you might consider your next steps:

  • Install Different Version: If you plan to reinstall Node.js, consider using a version manager like nvm (Node Version Manager). This tool allows you to manage multiple versions easily.

  • Address Errors: If you were uninstalling Node.js due to errors, ensure you troubleshoot any existing issues before a fresh installation.

  • Check Project Dependencies: If you’re developing applications, verify that your project dependencies are compatible with the version of Node.js you intend to install next.

Conclusion

In conclusion, uninstalling Node.js from your Mac can be straightforward when you understand the steps involved.

By using methods such as Homebrew or manual file removal, you can ensure that all components of Node.js are thoroughly removed from your system.

Remember to confirm its uninstallation by checking for any residual files and verifying that both Node.js and NPM commands return errors indicating they are no longer in use.

By knowing how to uninstall Node on Mac, you are now prepared to manage your Node.js environment efficiently. Whether you’re refreshing your setup, resolving version issues, or troubleshooting errors, these steps will help you maintain a clean development environment on your Mac.