使用 nvm 卸载当前活动的 node.js 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47240567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:34:42  来源:igfitidea点击:

Uninstalling the currently active version of node.js with nvm

node.jsnpmuninstallnvm

提问by James Newton

On Ubuntu 16.04, I mistakenly used root to install nvm, and then to install node.js 8.8.1 via nvm. I also used nvm alias default 8.8.1, thinking it would correct my error.

在Ubuntu 16.04上,我错误地使用root安装nvm,然后通过nvm安装node.js 8.8.1。我也使用过nvm alias default 8.8.1,认为它会纠正我的错误。

Now I would like to:

现在我想:

  1. Remove the default alias
  2. Uninstall node 8.8.1
  3. Uninstall npm 4.8.5, which came along with node
  4. Uninstall nvm
  5. Reinstall everything correctly for the right non-sudo user
  1. 删除默认别名
  2. 卸载节点 8.8.1
  3. 卸载 node 附带的 npm 4.8.5
  4. 卸载 nvm
  5. 为正确的非 sudo 用户正确重新安装所有内容

It looks like I've succeeded with the first part:

看起来我已经成功完成了第一部分:

# nvm unalias default
Deleted alias default - restore it with `nvm alias "default" "8.8.1"`

But nvm refuses to uninstall node 8.8.1, because it is the only version installed:

但是 nvm 拒绝卸载节点 8.8.1,因为它是唯一安装的版本:

# nvm uninstall 8.8.1                                                                                                                             
nvm: Cannot uninstall currently-active node version, v8.8.1 (inferred from 8.8.1).

I am guessing that I first need to disactivate node 8.8.1, but I see nothing in the output of nvm --helpwhich would appear to do this.

我猜我首先需要停用节点 8.8.1,但我在输出中看不到任何nvm --help内容可以执行此操作。

What steps do I need to take to completely remove node.js, npm and nvm from the machine before re-installing everything correctly?

在正确重新安装所有内容之前,我需要采取哪些步骤才能从机器中完全删除 node.js、npm 和 nvm?

回答by Shar

First type

第一种

$ nvm deactivate

Then type

然后输入

$ nvm uninstall 8.8.1

回答by LAdams87

rm -Rf ~/.nvm

This is the nuclear option in my case. just -R would ask me if I really wanted to delete every file in the nvm folder.

就我而言,这是核选项。只是 -R 会问我是否真的想删除 nvm 文件夹中的每个文件。

回答by Arul Deepan

You can uninstall the nodejs by using the following command.

您可以使用以下命令卸载 nodejs。

yum remove nodejs

yum 删除 nodejs

However, this will not remove the nvm from your linux box. To remove that try the below command.

但是,这不会从您的 linux 盒子中删除 nvm。要删除它,请尝试以下命令。

nvm unload

虚拟机卸载