Uninstall and reinstall NVM on Linux.

To uninstall and reinstall NVM (Node Version Manager) on Linux, you can follow the steps below:

Uninstall NVM:

  1. Open a terminal or command line interface.
  2. Enter the following command to uninstall NVM:

    rm -rf ~/.nvm

    This command will delete the installation directory of NVM and its related files.

  3. Open your terminal configuration file (eg  ~/.bashrc, ~/.zshrcetc.).
  4. Find and delete lines related to NVM. These lines typically contain statements similar to the following:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

    Save and close the file after removing these lines.

  5. Restart Terminal for the changes to take effect.

Reinstall NVM:

  1. Open a terminal or command line interface.
  2. Enter the following commands to download and install NVM:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

    This command will download the installation script from NVM's GitHub repository and execute the installation process.

  3. Open your terminal configuration file (eg  ~/.bashrc, ~/.zshrcetc.).
  4. Check that the configuration file contains NVM related lines. If not, manually add the following to the configuration file:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

    Save and close the file.

  5. Restart Terminal for the NVM installation to take effect.

Now, you have successfully uninstalled and reinstalled NVM on Linux. You can use NVM to manage and switch between different Node.js versions. Note that the specific commands and steps may vary depending on the version of NVM, and the above steps are applicable to the current version of NVM. Before reinstalling, make sure to back up any important data.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/131637653