Attempting to install NodeJS 14 installs NodeJS 8 instead - node.js

I am having trouble installing&running nodejs on my ubuntu 18 pc.
I run following commands step by step:
sudo apt update
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt -y install nodejs
And later checked the version number:
node -v
v8.10.0
Later I removed nodejs and i tried to install nodejs 12, 13 and 11, every time it is installing v8.10.0.
Can anyone please help me in this case?

My theory is that node 8 is installed no matter what and that it's in your PATH with a higher priority. Try uninstalling all versions of node and run node -v to verify that. If that's the case, I suggest you try to find a way to uninstall that version of node before reinstalling the version you want.
Also by typing which node you can get the path of the current executable that is being called when you call the node command. It may be a symlink in which case ls -l of the returned path would show you to path pointed by it.
Anyway, I suggest using nvm (Node Version Manager). Documentation at https://nvm.sh

Guess it's nvm, run
nvm ls to list all the node versions
nvm use <node version you want to use>
nvm current to check the node version in use

Related

Node versions do not match: node vs. sudo node -v ... WSL2 Ubuntu 22.04.1

As you can see in the image below, I see two different versions of node depending on which command I run.
I need the newer version, but npm sees the old version.
Many times I've removed, purged, reinstalled, etc.
I tried installing nvm as root and setting the node version there, but that didn't help either.
If I use apt install nodejs instead of nvm, it tells me that I already have the newest version, which it believes is 12.22.9.
How do I get npm to recognize the newer version (18.12.1) of node that I installed via nvm?
It is because you have a different version of the Node.js which is installed for the root and that particular user.
First, you need to uninstall Node.js:
sudo apt-get remove nodejs
or
sudo npm rm npm -g
If you have any problem with the above commands, then after running which node command, go to that directory, and run the following commands:
rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
Do the same thing for the current user if needed.
The default Ubuntu/Debian package manager does not have the latest Node.js, and that's why whenever you try to install Node.js with apt install nodejs it says you have the latest version.
According to the official Node.js documentation, for installing the latest version, you should follow these steps:
Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
P.S: No need to run npm or node with sudo. Therefore, I highly recommend you to not use every command with sudo.

Installing node 7 on Centos machine

I am trying to install node 7 on my Centos machine because previous versions do not support the apn protocol for sending iOS notifications. So I tried to execute:
sudo yum install nodes
and both npm and node were installed but unfortunately the latter of version v6.10.0.
sudo npm install latest
changes nothing.
I found a post suggesting to update the rpm repository, but that changes nothing; I even tried to change the command to:
sudo curl -sL https://rpm.nodesource.com/setup_7.x | sudo -E bash -
but when I tried to install node again, still the 6.10 version came out.
How may I force npm to adopt node7 as the stable or latest version?
Or what other way there exists to install node 7 instead of 6.10 for the good?
Another way is to use nvm (Node Version manager). First remove node and npm, then :
curl https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 7
nvm use 7
Then check version with :
node -v
nvm ls

Can somebody please tell me if I am using the wrong node js version?

I have been trying to update nodejs for a long time now. When I run node -v, it tells me I am using: v0.10.40. But when I look at nodejs.org it says the v7.4.0?
I have cleaned the npm cache and done a reinstall with sudo n stable but still v0.10.40, and the last time that I updated npm it prompted me that my node version is too old and outdated.
What am I doing wrong. And can somebody tell me if v0.10.40 is the current or an outdated version?
You likely have two versions of node installed and in your path. If you are on OSX or linux, run which node (if on Windows, you may npm i -g #raider/which, and then run which node). This should give you the location of the old version of node.
Then run mv path/to/old/node path/to/old/node.bak, replacing with the actual path, and rerun node --version to see if it picks up the right version now.
UPDATE: If you are on Ubuntu or another Debian based Linux, you should install the latest with the following commands:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
UPDATE: If you are using nvm, run nvm install node followed by nvm use node in a new terminal to get the latest that nvm supports.

How to upgrade Node js version to 0.12.4 on Ubuntu

I want to upgrade Node JS version on Ubuntu.
I tried many commands but its version is still the older i.e v0.10.37.
I tried:
sudo npm install -g n
sudo n install 0.12.4
sudo n use 0.12.4
Also tried with nvm but non of them works for me. How can I upgrade Node Js version to 0.12.4?
Use npm in order to upgrade node
First Clean the cache and try
sudo npm cache clean -f
sudo npm install -g n
sudo n 0.12.4
Then create a symbolic link(It is needed only sometimes, first try with these three commands. If it doesnot work add this.)
It will be updated to 0.12.4 Version.
It could be enough just to install n module:
sudo npm install -g n
and then simply run:
sudo n 0.12.4
The trick is that it may not be updated in your current terminal session. So you can simply open one more tab in your terminal or just another terminal and check your nodejs version by:
node --version
That's it, output will be v0.12.4
The official doc from nodejs repository points to this : https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories#installing-node-js-v0-12
Just follow it and you'll have the 0.12.4.
Try running this in terminal:
nvm install 5.10.1
nvm use 5.10.1
The version may be change.
Cheers!
Execute following comand to upgrade nodejs to 0.12.x
Note the new setup script name for Node.js v0.12
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
Then install with:
sudo apt-get install -y nodejs
Just ignore warning. By executing both commands it worked for me on Ubuntu 14.04
On Ubuntu 16.04
There is no special or dedicated comand to upgrade node version. The correct way to install or upgrade node on ubuntu is:
1) download the distribution you wish from nodejs official site, move the file into a known path
2) open a terminal and run: >sudo tar -C /usr/local --strip-components 1 -xzf "known path/name_of_the_distribution_file...gz
3) test if everything is ok: open a new terminal and run node --version. It should echo the version you downloaded and installed/upgraded.

Installing nvm on Ubuntu 14.04

I'm trying to install nvm on Ubuntu 14.04 but it doesn't seem to use the version I specify. I installed following the tutorial here https://github.com/creationix/nvm and I've also tried the one here https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps.
There are 2 node installations on my system already.
which node # => /usr/local/bin/node
node --version # => v0.11.13-pre
which nodejs # => /usr/bin/nodejs
nodejs --version # => v0.10.26
When I install nvm using the curl one liner they give you, and then use
nvm install 0.10.32
It creates an empty folder inside .nvm/v0.10.32 and .nvm/current symlinks to it.
In addition the bin folder is also empty. This problem occurs if I install other
versions of node. I suppose I could just clone a version of node into the folder
its supposed to go in but idk if that's all I have to do. In addition, I'm not sure
I know how to make my system use the nvm current (symlink from /usr/local/bin/node to .nvm/current ?) Without doing anything myself and only following the tutorial, node --version and nodejs --version never uses the version I specify with.
nvm use 0.10.32
Here is my personal guide how to install nvm (node version manager).
reference: https://github.com/creationix/nvm
1.) Install nvm (NOTE: There might be new versions in their website.)
curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash
2.) Close the current terminal and use a new terminal then try nvm again.
3.) Install current node.js version by using:
nvm install node_version
ex: nvm install 0.10.32
4.) to check the nodejs version--> nvm list
5.) Setup a default node version in nvm so that everytime you restart
the system it loads a default node version:
to get help: nvm -h
to get list of install node.js versions: nvm ls
to set a default alias: nvm alias default node_version
6.) Uninstall a specific node.js version:
nvm uninstall node_version
I understand that my answer may be outdated, but there was a very nice thesis in the ticket #809, that using
$ npm install -g nvm
is wrong. To fix, you want to do
$ npm uninstall -g nvm
$ apt install curl
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
$ source ~/.bashrc
$ nvm install 5.1
$ nvm use 5.1
instead (given that curl hasn't yet been installed on that machine).
I just removed all of the offending node installations until my system used a version that was 0.10.* . It appears I tried to install node before or another program installed it.

Resources