node.js 在ubuntu 14.04完全卸载nodejs、npm和node
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32426601/
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
Completly uninstall nodejs, npm and node in ubuntu 14.04
提问by lpares12
I know this question has been asked many times but I couldn't still do it.
So I wrongly installed "node" doing sudo apt-get install nodeAnd later I installed nodejs (v0.10.37). I tried to update to v0.12 with npm but it keeps saying 0.10.37 when I do the nodejs -v. Also, I can't use the node command since i wrongly installed the other "node thing" before.
I tried all the different commands that the people talks about in all the other answers and I couldn't do it yet.
I think the main problem is that I keep having the wrong node package and installing the nodejs-legacy doesn't work.
Also the npm installcommand works and creates the folder with the files but my App still says that the libraries are missing.
我知道这个问题已经被问过很多次了,但我还是做不到。所以我错误地安装了“node” sudo apt-get install node,后来我安装了nodejs(v0.10.37)。我尝试使用 npm 更新到 v0.12,但是当我执行nodejs -v. 另外,我无法使用 node 命令,因为我之前错误地安装了另一个“节点”。我尝试了人们在所有其他答案中谈论的所有不同命令,但我还做不到。我认为主要问题是我一直有错误的节点包并且安装 nodejs-legacy 不起作用。该npm install命令也可以工作并使用文件创建文件夹,但我的应用程序仍然说缺少库。
回答by Raja
sudo apt-get remove nodejs
sudo apt-get remove npm
Then go to /etc/apt/sources.list.d and remove any node list if you have. Then do a
然后转到 /etc/apt/sources.list.d 并删除任何节点列表(如果有)。然后做一个
sudo apt-get update
Check for any .npm or .node folder in your home folder and delete those.
检查主文件夹中的任何 .npm 或 .node 文件夹并删除它们。
If you type
如果你输入
which node
you can see the location of the node. Try which nodejsand which npmtoo.
你可以看到节点的位置。尝试which nodejs和which npm太。
I would recommend installing node using Node Version Manager(NVM). That saved a lot of head ache for me. Because you can install nodejs and npm without sudo using nvm.
我建议使用节点版本管理器(NVM)安装节点。这为我节省了很多头痛。因为您可以使用 nvm 在没有 sudo 的情况下安装 nodejs 和 npm。
回答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.
这帮助我解决了我的问题。
回答by Amit Malik
To remove nodejs, npm and node_modules from Ubuntu, you need to remove containers also which are at different locations in Ubuntu.
要从 Ubuntu 中删除 nodejs、npm 和 node_modules,您还需要删除位于 Ubuntu 中不同位置的容器。
These could be:
这些可能是:
/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
I did it successfully. So I am sharing the full procedure.
我成功地做到了。所以我分享了完整的程序。
You need to follow the steps that are described here: 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
回答by Kishan Jasani
To completely uninstall node js from Ubuntu
从 Ubuntu 完全卸载 node js
To manually remove node js, npm and node_modules from Ubuntu, you need to do the following steps.
要从 Ubuntu 手动删除 node js、npm 和 node_modules,您需要执行以下步骤。
- First of all you need to run the following command from command terminal as sudo.
- 首先,您需要从命令终端以 sudo 身份运行以下命令。
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
须藤 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
- Remove node or node_modules directories from /usr/local/lib with the help of following command.
- 借助以下命令从 /usr/local/lib 中删除 node 或 node_modules 目录。
sudo rm -rf /usr/local/lib/node*
须藤 rm -rf /usr/local/lib/node*
- Remove node or node_modules directories from /usr/local/include with the help of following command.
- 借助以下命令从 /usr/local/include 中删除 node 或 node_modules 目录。
sudo rm -rf /usr/local/include/node*
须藤 rm -rf /usr/local/include/node*
- Remove any node file or dir from /usr/local/bin with the help of following command.
- 借助以下命令从 /usr/local/bin 中删除任何节点文件或目录。
sudo rm -rf /usr/local/bin/node*
须藤 rm -rf /usr/local/bin/node*
- Go to home directory and remove any node or node_modules directory, if exists.
- 转到主目录并删除任何节点或 node_modules 目录(如果存在)。
回答by Nitin Raturi
Note: This will completely remove nodejs from your system; then you can make a fresh install from the below commands.
注意:这将从您的系统中完全删除 nodejs;然后您可以从以下命令进行全新安装。
Removing Nodejs and Npm
删除 Nodejs 和 Npm
sudo apt-get remove nodejs npm node
sudo apt-get purge nodejs
Now remove .node and .npm folders from your system
现在从系统中删除 .node 和 .npm 文件夹
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/share/man/man1/node*
sudo rm -rf /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm
sudo rm -rf ~/.node-gyp
sudo rm -rf /opt/local/bin/node
sudo rm -rf opt/local/include/node
sudo rm -rf /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*
Go to home directory and remove any node or node_modules directory, if exists.
转到主目录并删除任何节点或 node_modules 目录(如果存在)。
You can verify your uninstallation by these command, they should not output anything.
您可以通过这些命令验证您的卸载,它们不应输出任何内容。
which node
which nodejs
which npm
Installing NVM (Node Version Manager) script
安装 NVM(节点版本管理器)脚本
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
The command above will clone the NVM repository from Github to the ~/.nvm directory:
上面的命令会将 NVM 存储库从 Github 克隆到 ~/.nvm 目录:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
=> 关闭并重新打开终端以开始使用 nvm 或运行以下命令以立即使用它:
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
As the output above says, you should either close and reopen the terminal or run the commands to add the path to nvm script to the current shell session. You can do whatever is easier for you.
正如上面的输出所说,您应该关闭并重新打开终端,或者运行命令将 nvm 脚本的路径添加到当前的 shell 会话中。你可以做任何对你来说更容易的事情。
Once the script is in your PATH, verify that nvm was properly installed by typing:
一旦脚本位于您的 PATH 中,请通过键入以下内容验证 nvm 是否已正确安装:
nvm --version
# Output
0.34.0
Installing Node.js and npm
安装 Node.js 和 npm
nvm install node
nvm install --lts
Once the installation is completed, verify it by printing the Node.js version:
安装完成后,通过打印 Node.js 版本来验证它:
node --version
#Output
v12.8.1
Npm should also be installed with node, verify it using
Npm 也应该与 node 一起安装,验证它使用
npm -v
# Output
6.13.4
Extra - [Optional] You can also use two different versions of node using nvm easily
额外 - [可选] 您还可以使用 nvm 轻松使用两个不同版本的节点
nvm install 8.10.0 # just put the node version number Now switch between node versions
nvm install 8.10.0 # 只放节点版本号 现在在节点版本之间切换
nvm ls
#output
-> v12.14.1
v13.7.0
default -> lts/* (-> v12.14.1)
node -> stable (-> v13.7.0) (default)
stable -> 13.7 (-> v13.7.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.14.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.18.1 (-> N/A)
In my case v12.14.1 and v13.7.0 both are installed, to switch I have to just use
在我的情况下 v12.14.1 和 v13.7.0 都安装了,要切换我必须使用
nvm use 12.14.1
Configuring npm for global installations In your home directory, create a directory for global installations:
为全局安装配置 npm 在您的主目录中,为全局安装创建一个目录:
mkdir ~/.npm-global
Configure npm to use the new directory path:
配置 npm 以使用新的目录路径:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a ~/.profile fileif does not exists and add this line:
在您首选的文本编辑器中,如果不存在,打开或创建一个 ~/.profile 文件并添加以下行:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
在命令行上,更新您的系统变量:
source ~/.profile
That's all
就这样
回答by S.Yadav
It bothered me too much while updating node version from 8.1.0 to 10.14.0
将节点版本从 8.1.0 更新到 10.14.0 时让我很困扰
here is what worked for me-
这对我有用-
- open terminal
(crtl+alt+t). - type
which node, will give path something like /usr/local/bin/noderm -rf node, will remove nodenode -v, no node version ...curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -sudo apt-get install -y nodejs
- 打开终端
(crtl+alt+t)。 - type
which node,会给出类似的路径 /usr/local/bin/noderm -rf node, 将删除节点node -v, 无节点版本...curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -sudo apt-get install -y nodejs
Note:-if you are getting error like-
注意:-如果您遇到错误,例如-
node /usr/bin/env: node: No such file or directory
just run-
赶紧跑-
ln -s /usr/bin/nodejs /usr/bin/node
sorce here
从这里开始
node -v// will givev10.14.0
node -v// 会给v10.14.0
Worked for me.
对我来说有效。
回答by DarckBlezzer
I was crazy delete node and npm and nodejs from my ubuntu 14.04 but with this steps you will remove it...
我很疯狂地从我的 ubuntu 14.04 中删除了 node、npm 和 nodejs,但是通过这些步骤,您将删除它...
sudo apt-get uninstall nodejs npm node
sudo apt-get remove nodejs npm node
if you uninstall correctly and it is still there, beffore this check links at bottom...
如果您正确卸载并且它仍然存在,请在检查底部链接之前...
//this will fine the `/usr/bin` or `/usr/local/bin`
find / -name "node"
// check path of program...
ls -l node
//and remove it
rm -rf /usr/bin/node
More information
Remove - Official website
If you installed via git repositoryTry purge nodejs npm and node
更多信息
Remove - 官网
如果你是通过 git repository 安装的Try purge nodejs npm and node
回答by Gayan Weerakutti
For those who installed node.js via the package manager, can just run:
对于那些通过包管理器安装 node.js 的人,可以运行:
sudo apt-get purge nodejs
Optionally if you have installed it by adding the official NodeSource repository as stated in "Installing Node.js via package manager", do:
如果您已按照“通过包管理器安装 Node.js”中所述添加官方 NodeSource 存储库来安装它,请执行以下操作:
sudo rm /etc/apt/sources.list.d/nodesource.list
If you want to clean up npm cache as well:
如果您还想清理 npm 缓存:
rm -rf ~/.npm
It is bad practice to try to remove things manually, as it can mess up the package manager, and the opearating system itself.
尝试手动删除内容是不好的做法,因为它会弄乱包管理器和操作系统本身。
回答by Silah Kosgei
To manually remove node js, npm and node_modules from Ubuntu, you need to do the following steps.
要从 Ubuntu 手动删除 node js、npm 和 node_modules,您需要执行以下步骤。
- First of all you need to run the following command from command terminal as sudo.
- 首先,您需要从命令终端以 sudo 身份运行以下命令。
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
须藤 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
- Remove node or node_modules directories from /usr/local/lib with the help of following command.
- 借助以下命令从 /usr/local/lib 中删除 node 或 node_modules 目录。
sudo rm -rf /usr/local/lib/node*
须藤 rm -rf /usr/local/lib/node*
- Remove node or node_modules directories from /usr/local/include with the help of following command.
- 借助以下命令从 /usr/local/include 中删除 node 或 node_modules 目录。
sudo rm -rf /usr/local/include/node*
须藤 rm -rf /usr/local/include/node*
- Remove any node file or dir from /usr/local/bin with the help of following command.
- 借助以下命令从 /usr/local/bin 中删除任何节点文件或目录。
sudo rm -rf /usr/local/bin/node*
须藤 rm -rf /usr/local/bin/node*
- Go to home directory and remove any node or node_modules directory, if exists.
- 转到主目录并删除任何节点或 node_modules 目录(如果存在)。
Now it is done
现在完成了
回答by Ruan Nawe
sudo apt-get install nodejs
sudo apt-get install aptitude
sudo aptitude install npm

