Home > Web Front-end > JS Tutorial > How to Completely Uninstall Node.js and NVM on macOS and Reinstall Them Cleanly?

How to Completely Uninstall Node.js and NVM on macOS and Reinstall Them Cleanly?

Patricia Arquette
Release: 2024-12-15 16:06:20
Original
108 people have browsed it

How to Completely Uninstall Node.js and NVM on macOS and Reinstall Them Cleanly?

How to Completely Uninstall Node.js and NVM and Reinstall from Scratch (Mac OS X)

Problem:

Despite installing Node.js and NVM (Node Version Manager), the Node.js version remains stuck at v0.6.1-pre, even after updating it.

Background:

  • NVM requires a PATH modification in $HOME/.bashrc.
  • On Mac OS X, Node.js and related files are typically stored in the following locations:

    • /usr/local/bin
    • /usr/local/include
    • /usr/local/lib
  • NVM may also create a local folder in the user's home directory containing Node.js and npm files.

Solution:

  1. Uninstall Node.js:

    • Manually delete the following files and directories:

      • /usr/local/bin/node
      • /usr/local/include/node
      • /usr/local/lib/node_modules (if present)
      • /usr/local/lib/dtrace/node.d (if present)
    • Run the following command:

      brew uninstall node
      Copy after login
  2. Uninstall NVM:

    • Open $HOME/.bash_profile or $HOME/.bashrc and remove any references to NVM.
  3. Delete Local Folders:

    • Check your home directory for folders named "local", "lib", or "include" and delete any "node" or "node_modules" directories within them.
  4. Reinstall Node.js and NVM:

    • Download and install Node Version Manager (NVM).
    • Use NVM to install the desired version of Node.js.
    • If necessary, reinstall npm using:

      npm install -g npm
      Copy after login
  5. Additional Steps (Optional):

    • Run the following command to remove any remaining Node.js or npm files:

      sudo rm -rf /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules
      sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node.1 /usr/local/lib/dtrace/node.d
      Copy after login

By following these steps, you can completely uninstall Node.js, NVM, and related files, and reinstall the entire system from scratch.

The above is the detailed content of How to Completely Uninstall Node.js and NVM on macOS and Reinstall Them Cleanly?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template