使用 Linux 命令行卸载 Node.JS?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5650169/
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-08-04 00:39:36  来源:igfitidea点击:

Uninstall Node.JS using Linux command line?

linuxnode.jscommand-line

提问by abe

How do you uninstall node.js using the cmd line in linux?

你如何在 linux 中使用 cmd 行卸载 node.js?

采纳答案by Bryan Field

Running which nodewill return something like /path/bin/node.

运行which node将返回类似/path/bin/node.

Then run cd /path

然后运行 cd /path

This is all that is added by Node.JS.

这就是 Node.JS 添加的全部内容。

rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1

Now the only thing I don't know about is npm and what it has installed. If you install npm again into a custom path that starts off empty, then you can see what it adds and then you will be able to make a list for npm similar to the above list I made for node.

现在我唯一不知道的是 npm 以及它安装了什么。如果您再次将 npm 安装到从空开始的自定义路径中,那么您可以看到它添加的内容,然后您将能够为 npm 制作一个列表,类似于我为 node 制作的上述列表。

回答by Justin Ethier

If you installed from source, you can issue the following command:

如果从源代码安装,则可以发出以下命令:

sudo make uninstall

If you followed the instructions on https://github.com/nodejs/node/wikito install to your $HOME/local/node, then you have to type the following before the line above:

如果您按照https://github.com/nodejs/node/wiki上的说明安装到您的 $HOME/local/node,那么您必须在上面的行之前键入以下内容:

./configure --prefix=$HOME/local/node

回答by Josh

To uninstall node I followed the accepted answer by @George, as I no longer have the sources, but before doing so I ran:

为了卸载节点,我遵循了@George 接受的答案,因为我不再拥有源代码,但在此之前我运行了:

sudo npm rm npm -g

That seemed to get rid of npm from the system directories such as /usr/bin/npmand /usr/lib/npm. I got the command from here. I then found a ~/.npmdirectory, which I deleted manually. Honestly I don't know if every trace of npm has been removed, but I can't find anything else.

这似乎从系统目录中删除了 npm,例如/usr/bin/npm/usr/lib/npm。我从这里得到了命令。然后我找到了一个~/.npm目录,我手动删除了它。老实说,我不知道 npm 的所有痕迹是否都已删除,但我找不到其他任何东西。

回答by spencercooly

if you want to just update node, there's a neat updater too

如果你只想更新节点,也有一个整洁的更新程序

https://github.com/creationix/nvm

https://github.com/creationix/nvm

to use,

使用,

git clone git://github.com/creationix/nvm.git ~/.nvm

source ~/.nvm/nvm.sh

nvm install v0.4.1

git 克隆 git://github.com/creationix/nvm.git ~/.nvm

源 ~/.nvm/nvm.sh

nvm 安装 v0.4.1

回答by Manoj Gupta

In Ubuntu 12.04simply type this

Ubuntu 12.04 中只需输入这个

$ sudo apt-get remove nodejs

It will uninstall nodejs and npmas well simple.

它将卸载 nodejs 和 npm也很简单。

回答by Christopher Gray

after installing using the "ROCK-SOLID NODE.JS PLATFORM ON UBUNTU" script, i get this output. Which tells you how to uninstall nodejs.

使用“ROCK-SOLID NODE.JS PLATFORM ON UBUNTU”脚本安装后,我得到了这个输出。它告诉你如何卸载 nodejs。

Done. The new package has been installed and saved to

/tmp/node-install/node-v0.8.19/nodejs_0.8.19-1_i386.deb

You can remove it from your system anytime using:

  dpkg -r nodejs

完毕。新包已经安装并保存到

/tmp/node-install/node-v0.8.19/nodejs_0.8.19-1_i386.deb

您可以随时使用以下方法将其从系统中删除:

  dpkg -r nodejs

回答by Yaki Klein

The answer of George Bailey works fine. I would just add the following flags and use sudo if needed:

George Bailey 的回答很好。如果需要,我会添加以下标志并使用 sudo :

 sudo rm -rf bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node

回答by T04435

Best way to go around this is to do it right from the BEGINNING:

解决这个问题的最好方法是从 BEGINNING 开始:

INSTALL BREW

安装酿造

#HERE IS HOW: PASTE IN TERMINAL

sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"

Then at the end of your .bashrc file(In your home directory press Ctrl + H)

然后在 .bashrc 文件的末尾(在您的主目录中按 Ctrl + H)

export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

Then restart terminal so the modification to .bashrc are reloaded

然后重新启动终端,以便重新加载对 .bashrc 的修改

TO INSTALL NODE

安装节点

brew install node

TO CHECK VERSION

检查版本

node -v
npm -v

TO UPDATE NODE

更新节点

brew update
brew upgrade node

TO UNINSTALL NODE

卸载节点

brew uninstall node

回答by Saheed

If you installed node using curl+ yum:

如果您使用curl+安装节点yum

sudo curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
sudo yum -y install nodejs

Then you can remove it using yum:

然后您可以使用yum以下方法删除它:

sudo yum remove nodejs

Note that using the curlscript causes the wrong version of node to be installed. There is a bugthat causes nodev6.7 to be installed instead of v4.x intended by the path (../setup_4.x)used in the curlscript.

请注意,使用该curl脚本会导致安装错误版本的节点。有一个错误会导致node安装 v6.7 而不是脚本中(../setup_4.x)使用的路径所预期的 v4.x。curl

回答by Amit Malik

This is better to remove NodeJS and its modules manually because installation leaves a lot of files, links and modules behind and later it create problems while we reconfigure another version of NodeJS and its modules. Run the following commands.

最好手动删除 NodeJS 及其模块,因为安装会留下大量文件、链接和模块,然后在我们重新配置另一个版本的 NodeJS 及其模块时会产生问题。运行以下命令。

sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules 


sudo rm -rf /usr/local/lib/node*     
sudo rm -rf /usr/local/include/node*         
sudo rm -rf /usr/local/bin/node*

and this done.

这完成了。

A step by step guide with commands is at http://amcositsupport.blogspot.in/2016/07/to-completely-uninstall-node-js-from.html

带命令的分步指南位于http://amcositsupport.blogspot.in/2016/07/to-completely-uninstall-node-js-from.html

This helped me resolve my problem.

这帮助我解决了我的问题。