📅  最后修改于: 2023-12-03 14:44:50.415000             🧑  作者: Mango
NVM (Node Version Manager) is a tool that allows for easy installation and management of multiple versions of Node.js on a single machine. It provides a simple command-line interface for installing, switching between, and uninstalling different Node versions.
However, sometimes when trying to uninstall a Node version, you may encounter an error message like the following:
nvm: Cannot uninstall currently-active node version, v14.14.0 (inferred from node)
This error message indicates that the Node version you are trying to uninstall is currently active, meaning that it is currently being used by some process or application. In this article, we will discuss why this error occurs and how to fix it.
This error occurs because NVM cannot uninstall a Node version that is currently active. When you try to uninstall a Node version, NVM needs to switch to a different Node version first, but it cannot do so if the Node version you are trying to uninstall is currently in use.
To fix this error, you need to first switch to a different Node version using the nvm use
command. Once you have switched to a different Node version, you can then try to uninstall the Node version that was previously active.
Here are the steps you can follow to fix this error:
List the available Node versions using the command: nvm ls
Choose a different Node version that you want to switch to and install it using the command: nvm install <version>
Switch to the newly installed Node version using the command: nvm use <version>
Verify that you have switched to the correct Node version using the command: node -v
Try to uninstall the previously active Node version using the command: nvm uninstall <version>
If you have followed these steps correctly, you should be able to uninstall the Node version without encountering any errors.
Note that if you are still encountering the error even after switching to a different Node version, it may be because some process or application is still using the Node version you are trying to uninstall. In this case, you may need to stop those processes or close those applications before trying to uninstall the Node version again.
In this article, we have discussed why the error message "nvm: Cannot uninstall currently-active node version" occurs and how to fix it. By following the steps outlined in this article, you should be able to uninstall the Node version without encountering any errors.