Home > Web Front-end > JS Tutorial > How to Completely Uninstall and Reinstall Node.js on macOS to Fix Version Discrepancies?

How to Completely Uninstall and Reinstall Node.js on macOS to Fix Version Discrepancies?

Linda Hamilton
Release: 2024-12-16 14:19:10
Original
498 people have browsed it

How to Completely Uninstall and Reinstall Node.js on macOS to Fix Version Discrepancies?

Complete Uninstallation and Reinstallation of Node.js on Mac OS X

Encountering persistent discrepancies between installed and reported Node.js versions can be frustrating. To resolve this issue and perform a clean reinstallation, follow these comprehensive steps.

Uninstallation:

  1. Remove Files from User Home Directory: Delete all "local," "lib," and "include" folders containing "node" or "node_modules" from within the user's home directory.
  2. Delete Node.js Directories: Remove any "node" or "node_modules" directories from the following locations:

    • /usr/local/lib
    • /usr/local/include
    • /usr/local/bin
  3. Uninstall Brew Version (if Installed): If Node.js was installed via Brew, enter the following command in the terminal: brew uninstall node
  4. Remove Remaining Files: Execute the following command:
sudo rm -rf \
/usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
Copy after login

Reinstallation:

  1. Install NVM: Download and install NVM according to the official instructions.
  2. Install Node.js: Use NVM to install the desired version of Node.js. The latest versions of Node.js come bundled with NPM, but it can also be reinstalled separately.

Additional Notes:

  • NVM modifies the PATH variable in ~/.bashrc. Revert any changes made by NVM manually.
  • If you encounter further issues, consult the provided edit for the original post for additional instructions.

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