2

I had installed node and npm via : $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.)

So I set to uninstall 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/

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 ? Or uninstall and clean the 4.2.6 ?

3
  • Use this command for uninstall and clean: sudo apt-get remove <application_name> but this question stack overflow askubuntu.com/questions/1143/how-can-i-uninstall-software Commented Oct 12, 2017 at 0:37
  • This is specific to nodejs uninstall/install sudo apt-get install -y nodejs Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libuv1 The following NEW packages will be installed: libuv1 nodejs 0 upgraded, 2 newly installed, 0 to remove and 203 not upgraded. Need to get 3,161 kB/3,218 kB of archives. After this operation, 13.4 MB of additional disk space will be used. Get:1 archive.ubuntu.com/ubuntu xenial-updates/universe amd64 nodejs amd64 4.2.6~dfsg-1ubuntu4.1 [3,161 kB] Commented Oct 12, 2017 at 0:41
  • @SamDev : this is very specific to nodejs and ubuntu and not "how to uninstall any package". I would appreciate if you can read the full question Commented Oct 12, 2017 at 0:45

2 Answers 2

5

You can install node using NVM (Node Version Manager)

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 should now be installed.

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. 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 

also you can set a default version using

nvm alias default 6.11.4 
Sign up to request clarification or add additional context in comments.

Comments

0

Go to node.org website

download binaries

unpack it

replace original files with unpacked content

for example

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.