简体   繁体   English

如何在Ubuntu 16.04上清理卸载Node.js / Node

[英]How to Clean uninstall nodejs / node on ubuntu 16.04

I had installed node and npm via : $sudo apt-get install npm 我已经通过以下方式安装了节点和npm: $sudo apt-get install npm

then I realised the node version was 4.2.6, which I could not run my code ( some function syntax errors/ type erros etc.) 然后我意识到节点版本是4.2.6,我无法运行我的代码(某些函数语法错误/类型错误等)。

So I set to uninstall nodejs: 所以我设置要卸载nodejs:

sudo apt-get remove npm sudo apt-get purge nodejs sudo apt-get autoremove rm -r /usr/local/bin/npm rm -rf ~/.npm rm -rf /opt/local/bin/node rm -rf opt/local/include/node rm -rf /opt/local/lib/node_modules

Installing again with latest LTS, I am following install instructions from https://nodejs.org/en/download/package-manager/ 使用最新的LTS再次安装,我正在按照https://nodejs.org/en/download/package-manager/中的安装说明进行操作

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs

My Question: After above install nodejs version is still 4.2.6, How can I get the latest version ? 我的问题:以上安装后,nodejs版本仍然是4.2.6,如何获取最新版本? Or uninstall and clean the 4.2.6 ? 还是卸载并清洁4.2.6?

You can install node using NVM (Node Version Manager) 您可以使用NVM(节点版本管理器)安装节点

Do this: 做这个:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

this will download and execute the NVM installation script. 这将下载并执行NVM安装脚本。 NVM should now be installed. 现在应已安装NVM。

After that just use it to install node. 之后,只需使用它来安装节点。 Open a new terminal and for example do 打开一个终端,例如

nvm install 6.11.4

This installs node version 6.11.4, which is the latest LTS. 这将安装节点版本6.11.4,这是最新的LTS。 You can install any version you want. 您可以安装所需的任何版本。 Do

nvm ls-remote

to see all available versions and just replace the version number. 查看所有可用版本,只需替换版本号即可。

You can install any number of node versions, and switch between them using 您可以安装任意数量的节点版本,并使用

nvm use 6.11.4 nvm使用6.11.4

also you can set a default version using 您也可以使用

nvm alias default 6.11.4

Go to node.org website 转到node.org网站

download binaries 下载二进制文件

unpack it 打开包装

replace original files with unpacked content 用解压缩的内容替换原始文件

for example 例如

sudo mv ./bin/* /usr/bin/
sudo mv ./lib/* /usr/lib/
etc ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM