Node version doesn't change after attempted upgrade in Ubuntu - node.js

In my Ubuntu machine, I am attempting to update my version of Node. I run curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
then I run sudo apt-get install -y nodejs
After this, my version of node remains unchanged:
ubuntu:~$ node -v
v6.10.3

use nvm, a version manager for node
https://github.com/creationix/nvm
To download node you install nvm and type nvm install <version>
This will download both node and npm
To change which node version you want to use you type nvm use <version>
For more detail check out the repo ^^

Running this worked for me finally.
Uninstall:
sudo apt-get purge nodejs
sudo apt-get autoremove
nvm deactivate
nvm uninstall node_version
(Source)
Install the New Version:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
If there are errors here, run these 2:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
wget -qO - https://raw.githubusercontent.com/yarnpkg/releases/gh-pages/debian/pubkey.gpg | sudo apt-key add -
Install New Version of Node:
wget -qO - https://raw.githubusercontent.com/yarnpkg/releases/gh-pages/debian/pubkey.gpg | sudo apt-key add -

Related

Update to Node version 16 without installing package

I am trying to update my node version to 16.
Here what I am doing :
--installing nvm
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
-- nvm installer script creates environment entry to login script of the current user.
source ~/.profile
--node
nvm install 16
nvm use 16
What bothers me, is I need to install a package called nvm.
Is it possible to update node without installing a package ?
Advance Thanks,
Here my solution :
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt update
sudo apt upgrade

How To Install Node Js In Ubuntu 18.10?

i'm trying to install nodejs in Ubuntu 18.10 but it returns some error.
The following packages have unmet dependencies:
nodejs : Depends: python-minimal but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Above is the message i get while install node Js by cammand: sudo apt-get install nodejs.
As described in this link:
Install node version manager:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
Activate nvm:
. ~/.nvm/nvm.sh
Use nvm to install the version of node you want:
nvm install 4.4.5
Test that Node.js is installed:
node -e "console.log('Running Node.js ' + process.version)"
The recommended way to install node under Ubuntu appears to be to use the archives provided by NodeSource.
Their instructions are to run these shell commands to, presumably, set up a PPM and install a current version of node from that source.
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
First you need to install python 2.7 using following commands
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python2.7
then install nodejs
sudo apt-get install nodejs
Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs
Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_15.x | bash -
apt-get install -y nodejs

Package 'npm' has no installation candidate

I want to install npm in Debian 9.
I've tried:
apt-get install nodejs
completely installed and nodejs -v results: v4.8.2.
but when try to run npm an error says:
bash: npm: command not found
Base on my searches I've tried other ways:
based on this guide: https://www.godaddy.com/help/install-nodejs-ubuntu-17395 I've tried:
sudo apt-get install npm
results:
E: Package 'npm' has no installation candidate
Based on another guide I've tried:
wget https://npmjs.org/install.sh
sudo chmod +x install.sh
sudo ./install.sh
results:
npm cannot be installed without node.js.
of course I've installed nodejs. I also tried this way:
curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get update
sudo apt-get install --yes nodejs
It says:
nodejs is already the newest version (4.8.2~dfsg-1).
What should I do?
Remove the old version
sudo apt-get purge nodejs
Install the new version:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Alternatively, for Node.js 9:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
Source
It might tell you that you are missing package gnupg2, just install it.

Error when adding generator-jhipster via YARN

I ran the following command to install the generator-jhipster via yarn:
yarn global add generator-jhipster
After doing so, I ran into the following issue:
The engine "node" is incompatible with this module. Expected version ">=6.9.5"
Any clue as to how I can get around this issue?
TIA
Install node 6.9.5 or more recent.
Update node to the latest version.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Once your install is complete, you can confirm you version with another command:
node -v
To Download latest node
https://nodejs.org/en/download/package-manager/
Node.js v5:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v6:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v7::
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v8::
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
You can also try to use
yarn --ignore-engines

updating nodejs on ubuntu 16.04

I was recently going through the version of node in my ubuntu 16.04 when node -v command was used it shows me version 6.9.1 but when nodejs -v it shows 6.9.2 previously before using this commands npm update command was used.
Now what's these difference in node -v and nodejs -v? and how to update to the latest LTS version of node/nodejs?
To update, you can install n
sudo npm install -g n
Then just :
sudo n latest
or a specific version
sudo n 8.9.0
According to official docs to install node on Debian and Ubuntu based distributions:
node v12 (Old)
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
node v14 (For new users: install this one):
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
node v15 (Current version):
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs
Other older versions:
Just replace the desired version number in the link above.
Optional: install build tools
To compile and install native packages
sudo apt-get install -y build-essential
To update node to the latest version just:
sudo apt update
sudo apt upgrade
To keep npm updated
sudo npm i -g npm
To find out other versions try npm info npm and in versions find your desired version and replace [version-tag] with that version tag in npm i -g npm#[version-tag]
And I also recommend trying yarn instead of npm
Using Node Version Manager (NVM):
Install it:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Test your installation:
close your current terminal, open a new terminal, and run:
command -v nvm
Use it to install as many versions as u like:
nvm install 8 # Install nodejs 8
nvm install --lts # Install latest LTS (Long Term Support) version
List installed versions:
nvm ls
Use a specific version:
nvm use 8 # Use this version on this shell
Set defaults:
nvm alias default 8 # Default to nodejs 8 on this shell
nvm alias default node # always use latest available as default nodejs for all shells
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
Undo :
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Use sudo apt-get install --only-upgrade nodejs to upgrade node (and only upgrade node) using the package manager.
The package name is nodejs, see https://stackoverflow.com/a/18130296/4578017 for details.
You can also use nvm to install and update node.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
Then restart the terminal, use nvm ls-remote to get latest version list of node, and use nvm install lts/* to install latest LTS version.
nvm is more recommended way to install or update node, even if you are not going to switch versions.
Difference: When I first installed node, it installed as 'nodejs'. When I upgraded it, it created 'node'. By executing node, we are actually executing nodejs. Node is just a reference to nodejs.
From my experience, when I upgraded, it affected both the versions (as it is supposed to). When I do nodejs -v or node -v, I get the new version.
Upgrading: npm update is used to update the packages in the current directory. Check https://docs.npmjs.com/cli/update
To upgrade node version, based on the OS you are using, follow the commands here https://nodejs.org/en/download/package-manager/
Please refer nodejs official site for installation instructions at the following link
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Anyway, please find the commands to install nodejs version 10 in ubuntu below.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install npm#latest -g
Try this:
Edit or create the file :nodesource.list
sudo gedit /etc/apt/sources.list.d/nodesource.list
Insert this text:
deb https://deb.nodesource.com/node_10.x bionic main
deb-src https://deb.nodesource.com/node_10.x bionic main
Run these commands:
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
sudo sh -c "echo deb https://deb.nodesource.com/node_10.x cosmic main /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
sudo apt-get install nodejs
node and nodejs are two different packages in Ubuntu software, node is an up-to-date snap package, whereas nodejs is an older version of apt package
to update to the latest LTS version of node:
Install NVM on Ubuntu 22.04|20.04|18.04 with the command:
wget https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh
bash install.sh
After the installation, source the profile:
source ~/.bashrc
Verify the NVM installation:
nvm -v
Install Node.js 18 LTS on Ubuntu 22.04|20.04|18.04 as shown:
nvm install v18
Install the latest version using the command:
nvm install node
Once complete, verify the installation:
node -v
Run these commands:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
source ~/.profile
nvm ls-remote
nvm install v9.10.1
nvm use v9.10.1
node -v
Update latest version Nodejs :
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
I am using Ubuntu 20.04.4 LTS and got the issue during upgrade node js. The current LTS version is 16.14.2 According to the NodeSource Node.js Binary Distributions document
Node.js v16.x:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
if you still get the issue you can also try the following:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt-get update
sudo npm cache clean -f
sudo apt-get install -y nodejs
Node.js Current:
It's work for me..
Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_current.x | bash -
apt-get install -y nodejs
I am also facing problem while going to install react app, so i found the solution,
npx create-react-app shodkk
First install the npm latest version using
sudo npm install -g npm#8.4.1
So to install the node 16.x you need to go terminal and type
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
Doing this you install the node LTS that is 16.14.o at the time of writing this post.
Try this 2-3 times, also do the
sudo apt-get update
Then Now install the package using
sudo apt-get install -y nodejs
At last this helps you remove any unwanted package, that remains after updating that is depreciated and need not be there, So use autoremove command.
sudo apt autoremove
So if like the post, Upvote and motivate me to write more, thanks, givingBack to the Community.
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n

Resources