Home  >  Article  >  Web Front-end  >  nvm how to delete nodejs

nvm how to delete nodejs

PHPz
PHPzOriginal
2023-04-18 17:07:282262browse

Node.js is a popular server-side programming language, which in turn has led to the popularity of its package manager npm. However, when you need to uninstall Node.js or newer versions, you also need to uninstall npm. This article explains how to completely remove Node.js and npm.

Remove Node.js and npm on Windows

If Node.js and npm were installed on Windows through the Windows installer, then to uninstall just perform the following steps:

  1. Open the "Control Panel" and find the program list of Node.js and npm
  2. Double-click "Node.js" to delete it. If there are multiple versions, select the version you want to delete.

Note: This will only remove Node.js, not npm.

To delete npm, you need to run the following command as an administrator in a command line interface (such as PowerShell, Git Bash, or other):

npm uninstall npm -g

This command will completely delete npm. Additionally, you can check whether npm was successfully removed by running the following command:

npm -v

If the removal was successful, the command will output "command not found".

Remove Node.js and npm on macOS

Uninstalling Node.js and npm on macOS is easier than Windows. This can be achieved by:

  1. Open a terminal and enter the following command:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

This command will completely uninstall Node.js and npm.

After entering this command line, you need to enter your macOS user password.

  1. Check whether Node.js and npm are removed.

Run the following command in the terminal. If the uninstallation is successful, the command will output "command not found".

node -v
npm -v

Removing Node.js and npm on Linux

If you are using a Linux system, it is easier to remove Node.js and npm. You can uninstall Node.js and npm using your package manager.

  1. Open the terminal and enter the following command:
sudo apt-get remove nodejs

If you do not need the package manager npm for Node.js, you can completely uninstall it using the following command:

sudo apt-get remove npm
  1. If you need to install a higher version of Node.js, you can use the following command:
curl -sL https://deb.nodesource.com/setup_X.x | sudo -E bash -
sudo apt-get install -y nodejs

Replace X.x in the command with the version you need to install.

Run the following command in the terminal. If the uninstall is successful, the command will output "command not found".

node -v
npm -v

Conclusion

So, through the method in this article, you can completely uninstall Node.js and npm. Note, back up your code before uninstalling. At the same time, some methods for installing Node.js and npm are also provided here to facilitate you to program better. Happy programming!

The above is the detailed content of nvm how to delete nodejs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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