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

How to Completely Uninstall and Reinstall Node.js, npm, and NVM on macOS?

Mary-Kate Olsen
Release: 2025-01-01 01:29:11
Original
418 people have browsed it

How to Completely Uninstall and Reinstall Node.js, npm, and NVM on macOS?

How to Uninstall and Reinstall Node.js, npm, and NVM on Mac OS X

A user recently experienced a persistent outdated version of Node.js (v0.6.1-pre) despite installing newer versions. The investigation revealed a phantom node 0.6.1-pre version that persisted despite various uninstallation attempts.

Solution

The user identified a previously overlooked local folder under the user directory, which contained folders for include, lib, node, and node_modules. Deleting these local references resolved the issue.

Complete Uninstallation and Reinstallation

To completely uninstall Node.js, npm, and NVM and reinstall from scratch:

1. Remove Node.js

  • Go to usr/local/lib and delete any node and node_modules folders.
  • Go to usr/local/include and delete any node and node_modules folders.
  • If installed via brew, run brew uninstall node in the terminal.
  • Check the Home directory for any local, lib, or include folders and delete any node or node_modules folders.
  • Go to usr/local/bin and delete any node executable.

2. Additional Removal

Consider running the following commands as well:

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

3. Remove NVM

NVM modifies the PATH variable in $HOME/.bashrc; revert this manually.

4. Reinstallation

  • Download and install NVM.
  • Follow the instructions to install the desired Node.js version.
  • Reinstall npm if necessary.

The above is the detailed content of How to Completely Uninstall and Reinstall Node.js, npm, and NVM on macOS?. 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