Install node in Amazon Linux 2 - node.js

I purchased Amazon Linux 2 machine using AWS LightSail and tried to install node on that machine. But after several tries I can't able to install node and got the error shared below.
[root#ip-my public ip /]# sudo yum install nodejs
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:18.3.0-1nodesource will be installed
--> Processing Dependency: libc.so.6(GLIBC_2.28)(64bit) for package: 2:nodejs-18.3.0-1nodesource.x86_64
--> Processing Dependency: libm.so.6(GLIBC_2.27)(64bit) for package: 2:nodejs-18.3.0-1nodesource.x86_64
--> Finished Dependency Resolution
Error: Package: 2:nodejs-18.3.0-1nodesource.x86_64 (nodesource)
Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: 2:nodejs-18.3.0-1nodesource.x86_64 (nodesource)
Requires: libm.so.6(GLIBC_2.27)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
Thanks in advance!

I think AWS LightSail Amazon Linux 2 supports node version <=16.x,
So we want to install node version <=16, I installed node version 16 and it works!!
Here are the steps followed,
Step 1:- Configure Yum Repository
$ sudo yum install -y gcc-c++ make
$ curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
Step 2:– Install Node.js on Amazon Linux
$ sudo yum install -y nodejs
Step 3 – Check Version
$ node -v
$ npm -v

My solution to fix this problem, you must erase cache with this command:
sudo rm -R /var/cache/yum/x86_64/2/nodesource/
Now, you can download the correct version:
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
And now you can install:
sudo yum install -y nodejs

Related

Getting python2 error in nodejs installation in Ubuntu 20.04

I've updated to the new Ubuntu 20.04LTS version and all my node installations have gone. So to install node I have tried the following 2 methods:
1.sudo apt update
sudo apt install nodejs npm
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs
While installing nodejs I'm getting the error : nodejs : Depends: python2-minimal but it is not installable . Unable to correct problems, you have held broken packages.
screenshot
You need to install python2. Steps in Ubuntu 20
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install python2
This will install python2 successfully. Now you can continue with normal nodejs installation
I had a similar problem and solved it by following the instructions on https://speedysense.com/install-nodejs-on-ubuntu-20-04/
Tldr run these on a terminal: for current LTS Release (v14.x),
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Afterwards check your Nodejs and npm version by running these on a terminal:
node --version
npm --version

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

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

Install latest nodejs version in ubuntu 14.04

This is the way I installed nodejs in ubuntu 14.04 LTS:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
When I checked the node version with this:
node -v
I get this
v0.10.37
But the latest version is 4.2.6 and 5.5.0. How can I get the latest or update version?
sudo apt-get install curl
For Node.js v4
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
For 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 8:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
https://nodejs.org/en/download/package-manager/
On Ubuntu 14.04.5 LTSthe easier way is
1 Install npm:
sudo apt-get install npm
Install n
sudo npm install n -g
Get latest version of node
sudo n latest
If you prefer to install a specific version of `node you can
2.1 List available node versions
n ls
2.2 and the install a specific version
sudo n 4.5.0
There is an issue with node and npm update in Ubuntu14.04 LTS 64 bit OS. Since Google Chrome repository no longer provides 32-bit packages, 64-bit Ubuntu/Debian users will notice an error when updating the software sources, which looks as follows:
Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release
Unable to find expected entry 'main/binary-i386/Packages' in Release file (Wrong sources.list entry or malformed file)
Some index files failed to download. They have been ignored, or old ones used instead.
So to fix this issue, the repository must be specifically set for 64-bit only. This can be done by the command
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
i,e You should set it for 64 bit only before installing node.
So the exact procedure to install latest node and npm will be
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
I had such an issue and got this solution from here. Hope this will help someone.
Here i am going to tell you how to install nodejs compile and install into your Linux Server.
Step 1-:
$ cd /opt/
$ wget https://nodejs.org/dist/v6.2.1/node-v6.2.1.tar.gz
Extract the tar.gz source code
$ tar -xvf node-*.tar.gz
Step 2-:
Compile and install the nodejs.
$ cd node-v6.2.1
$ ./configure
$ make
$ sudo make install
Note-:
If you found error “make command not found”
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
Running Ubuntu Mate 14.04 LTS
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
nodejs -v
Checkout nvm. It manages node distributions for you, so you can have multiple projects running that use different nodejs versions.
nvm lets you choose exactly which version of node you need. With apt-get you will always only get the latest version that has been included into debian/ubuntu by those package maintainers, but those are usually very old. Especially in an area like nodejs, this is mostly not suitable.
This worked for me:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Hope it helps someone too :)
Assuming you already have npm package and want to upgrade nodejs version:
sudo npm install -g n
sudo n latest
In case you don't have installed npm package then itstall it using following command:
sudo apt-get install npm
On linux.
NVM (Node Version manager)
https://github.com/creationix/nvm
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, the install script hacks adds some auto sourcing to the end of your .barshrc. That works, but I prefer to remove the auto-added one and add my own:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
With this setup, you get for example:
which node
gives:
/home/ciro/.nvm/versions/node/v0.9.0/bin/node
and:
which vaca
gives:
/home/ciro/.nvm/versions/node/v0.9.0/bin/vaca
and if we want to use the globally installed module:
npm link vaca
node -e 'console.log(require.resolve("vaca"))'
gives:
/home/ciro/.nvm/versions/node/v0.9.0/lib/node_modules/vaca/index.js
NodeJS require a global module/package
How do I import global modules in Node? I get "Error: Cannot find module <module>"?
so we see that everything is completely contained inside the specific node version.
Tested in Ubuntu 17.10.
Better way to do is,
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
based on version can change, setup_6.x into 7,8 etc
wget -qO- https://deb.nodesource.com/setup_X.x | sudo bash -
sudo apt-get install -y nodejs
You may also need to restart your terminal, on Ubuntu 17 installing latest version of NodeJS with sudo n 9.0.0
if you check the version with node -v it won't report correctly, close the terminal, open a new terminal and check again with node -v it will be reporting correctly
The easiest way for me:
Download the latest version of nodejs in https://nodejs.org/en/
Change directory to: cd /usr/local
Install the binaries, by using the following command:
sudo tar --strip-components 1 -xJf ~/Downloads/node-v14.16.0-linux-x64.tar.xz
node -v
npm -v
Ubuntu 14.04 contains a version of Node.js in its default repositories that can be used to easily provide a consistent experience across multiple servers. The version in the repositories is 0.10.25. This will not be the latest version, but it should be quite stable.
In order to get this version, we just have to use the apt package manager. We should refresh our local package index prior and then install from the repositories:
sudo apt-get update
sudo apt-get install nodejs
If the package in the repositories suits your needs, this is all that you need to do to get set up with Node.js. In most cases, you'll also want to also install npm, which is the Node.js package manager. You can do this by typing:
sudo apt-get install npm
This will allow you to easily install modules and packages to use with Node.js.
Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejs instead of node. Keep this in mind as you are running software.

Install Node.js on Ubuntu

I'm trying install Node.js on Ubuntu 12.10 (Quantal Quetzal), but the terminal shows me an error about lost packages. I tried with this:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
But when I came to the last line sudo apt-get install nodejs npm shows this error:
Failed to install some packages. This may mean that
you requested an impossible situation or if you are using the distribution
distribution that some required packages have not yet been created or been
been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodejs: Conflicts: npm
E: Failed to correct problems, you have held broken packages.
Then I uninstalled the ppa:chris-lea/node.js and I was trying a second option:
sudo apt-get install node.js
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
The same error, the terminal says npm is the latest version, but it also shows me the text I shown in the top. I think the problem is ppa:chris-lea/node.js, but I don't know how solve it.
Simply follow the instructions given here:
Example install:
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
It installs current stable Node on the current stable Ubuntu. Quantal
(12.10) users may need to install the software-properties-common
package for the add-apt-repository command to work: sudo apt-get install software-properties-common
As of Node.js v0.10.0, the nodejs package from Chris Lea's repo
includes both npm and nodejs-dev.
Don't give sudo apt-get install nodejs npm. Just sudo apt-get install nodejs.
As of today, you can simply install it with:
sudo apt-get install nodejs
npm is automatically installed with Node.js in the latest version of Node.js. What do you see when you type node --version and npm --version in the terminal?
You can upgrade npm using npm itself as well:
[sudo] npm install -g npm
My apt-get was old and busted, so I had to install from source. Here is what worked for me:
# Get the latest version from nodejs.org. At the time of this writing, it was 0.10.24
curl -o ~/node.tar.gz http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
cd
tar -zxvf node.tar.gz
cd node-v0.6.18
./configure && make && sudo make install
These steps were mostly taken from joyent's installation wiki.
This is the best way to easyly install Node.js. This also is actual for Ubuntu 12.04 (Precise Pangolin), Ubuntu 13.04 (Raring Ringtail), and Ubuntu 14.04 (Trusty Tahr).
Adding Node.js repositories
[sudo] apt-get install python-software-properties
[sudo] apt-add-repository ppa:chris-lea/node.js
[sudo] apt-get update
Node.js installation
[sudo] apt-get install nodejs
Now checking Node.js version
node -v
Outputs
v0.10.20
This command should install npm
npm install
Check npm version
npm -v
Outputs
1.4.3
If for some reason, if you see npm is not installed, you may try running:
[sudo] apt-get install npm
To update npm you may try running:
[sudo] npm install -g npm
Now you can simply install with:
sudo apt-get install nodejs
sudo apt-get install npm
Make sure you have the Python and C interpreters/compilers preinstalled. If not, perform:
sudo apt-get install python g++ make
You can use nvm to install Node.js. It allows you work with different versions without conflicts.
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.19.0/install.sh | bash
nvm install v0.10.33
Just use nvm for Node.js version control - nvm.
Just follow the official instructions from here to install on Ubuntu
Installation instructions
Node.js LTS (as of 01/2022 is v16.x):
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js Current (as of 01/2022 is v17.x):
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v17.x:
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v16.x:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v14.x:
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v12.x:
curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
Optional: install build tools
To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
You can also compile it from source like this
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Find detailed instructions here
http://howtonode.org/how-to-install-nodejs
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
http://jstricks.com/install-node-js/
Follow the instructions given here at NodeSource which is dedicated to creating a sustainable ecosystem for Node.js.
For Node.js >= 4.X
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js is available as a snap package in all currently supported versions of Ubuntu. Specific to Node.js, developers can choose from one or more of the currently supported releases and get regular automatic updates directly from NodeSource. Node.js versions 6, 8, 9, 10, 11, 13, 14, 15, 16, 17 and 18 are currently available, with the Snap Store being updated within hours or minutes of a Node.js release.
Node.js can be installed with a single command, for example:
sudo snap install node --classic --channel 11/stable
The node snap can be accessed by the command node, for example:
$ node -v
v11.5.0
An up-to-date version of npm will installed as part of the node snap. npm should be run outside of the node repl, in your normal shell. After installing the node snap run the following command to enable npm update checking:
sudo chown -R $USER:$(id -gn $USER) /home/<b>your-username</b>/.config
Replace your-username in the above command with your own username. Then run npm -v to check if the version of npm is up-to-date. As an example I checked that npm was up-to-date, checked the version of an already installed package named yarn with the command npm list yarn and then updated the existing yarn package to the latest version with the command npm update yarn
Users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:
sudo snap refresh node --channel=11/stable
Users can test bleeding-edge versions of Node.js that can be installed from the latest edge channel by switching with:
sudo snap switch node --edge
This approach is only recommended for those users who are willing to participate in testing and bug reporting upstream.
Node.js LTS schedule
Release
Status
Codename
Initial release
LTS Start
Maintenance Start
Maintenance End
6.x
EOL
Boron
2016-04-26
2016-10-18
2018-04-30
2019-04-30
7.x
EOL
2017-05-30
2017-06-30
8.x
EOL
Carbon
2016-10-25
2017-10-31
2019-01-01
2019-12-31
9.x
EOL
2017-10-01
2018-06-30
10.x
EOL
Dubnium
2018-04-24
2018-10-30
2020-05-19
2021-04-30
11.x
EOL
2018-10-23
2019-06-01
12.x
Maintenance LTS
Erbium
2019-04-23
2019-10-21
2020-11-301
2022-04-30
13.x
EOL
2019-10-22
2020-06-01
14.x
Maintenance LTS
Fermium
2020-04-21
2020-10-27
2021-10-30
2023-04-30
16.x
Active LTS
Gallium
2021-04-20
2021-10-26
2022-10-18
2024-04-30
17.x
Current
2021-10-19
2022-04-01
2022-06-01
18.x
Current
2022-04-19
2022-10-25
2023-10-18
2025-04-30
I personally do it this way:
sudo apt-get install python g++ make
wget http://nodejs.org/dist/node-latest.tar.gz
tar xvfvz node-latest.tar.gz
cd node-v0.12.0
./configure
make
sudo make install
If you want to install particular version then download the version you want from the Node.js site and execute the last tree steps.
I would strongly suggest not using the default Node.js package from the distribution market, because it would be probably outdated (i.e., the current for the time of writing this in the Ubuntu market is v0.10.25 which is too outdated compared to the latest (v0.12.0)).
Here is the full description to create the first program using the express generator,
Ubuntu's package manager
To install Node.js and npm via apt-get, run these commands:
sudo apt-get update
sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo apt-get install npm
Express application generator:
$ npm install express-generator -g
Display the command options with the -h option:
$ express -h
Usage: express [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-e, --ejs add ejs engine support (defaults to jade)
--hbs add handlebars engine support
-H, --hogan add hogan.js engine support
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
--git add .gitignore
-f, --force force on non-empty directory
For example, the following creates an Express application named myapp in the current working directory:
$ express myapp
create : myapp
create : myapp/package.json
create : myapp/app.js
create : myapp/public
create : myapp/public/javascripts
create : myapp/public/images
create : myapp/routes
create : myapp/routes/index.js
create : myapp/routes/users.js
create : myapp/public/stylesheets
create : myapp/public/stylesheets/style.css
create : myapp/views
create : myapp/views/index.jade
create : myapp/views/layout.jade
create : myapp/views/error.jade
create : myapp/bin
create : myapp/bin/www
Then install dependencies:
$ cd myapp
$ npm install
Run the app with this command:
$ DEBUG=myapp:* npm start
Then load http://localhost:3000/ in your browser to access the application.
The generated application has the following directory structure:
├── app.js
├── bin
│ └── www
├── package.json
├── public
│ ├── images
│ ├── javascripts
│ └── stylesheets
│ └── style.css
├── routes
│ ├── index.js
│ └── users.js
└── views
├── error.jade
├── index.jade
└── layout.jade
7 directories, 9 files
Really simple:
sudo apt install nodejs
And then type:
nodejs
to use it.
sudo apt install nodejs
sudo apt install npm
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Install Node.js on Ubuntu 12.10 (Quantal Quetzal) or Ubuntu 14.04 LTS (Trusty Tahr) or Ubuntu 16.04.1 LTS (Xenial Xerus).
Please avoid installing Node.js with apt-get on Ubuntu. If you already installed Node.js with the built-in package manager, please remove that. (sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean)
The installation process on Linux is the same as on OS X.
With the provided script:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
$ nvm list
$ nvm ls-remote
$ nvm install 6.4.0
$ nvm use 6.4.0
$ nvm alias default 6.4.0
$ node -v
$ npm install -g npm
$ npm -v
Other issues while installing Node JS
Do not use sudo apt-get install nodejs npm. Always use sudo apt-get install nodejs
And If you get the error sudo: add-apt-repository: command not found just run this command prior to the second one above: sudo apt-get install software-properties-common
If sudo: add-apt-repository: command not found and needed to run sudo apt-get install python-software-properties before adding the repository
try to use a bash -r if you had an old version before or node / npm does not appear in your console
The linked instructions have been updated to curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs
Edit Updated
For the latest version you can also use the URL
nodejs.org/dist/node-latest.tar.gz
One more thing! Don’t forget to run the following command, which increases the amount of inotify watches.
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
If you're looking for a simple, fast (no build process), local (no sudo) install on ubuntu, check out:
install-node-on-linux
Disclaimer: I'm the author.
You just have to clone the repo and run setup.sh and you'll have the latest node version installed. If you want a specific version just run change-version.sh.
I've read the answers above and I tried, worked fine but sometimes you will face little problem while using that answers. What if you install the nodejs from Ubuntu store, I have tried and vallah, job done.
First you have to uninstall what old garbage you have install by
sudo apt-get remove nodejs
I was also trying to install node via apt but failing, or giving me the version 10.x.x which was outdated. I then randomly went to ubuntu store and installed the latest one, check it node --version
You can do it with just simple and easy commands
sudo apt-get update
Install Req. Files
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
Install Nodejs
sudo apt install nodejs
Check if is it installed properly.
node --version
For the latest Node.js
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install nodejs
node -v
npm -v
The Node.js package is available in the LTS release and the current release. It’s your choice to select which version you want to install on the system as per your requirements.
Use Current Release: At the last update of this tutorial, Node.js 13 is the current Node.js release available.
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
Use LTS Release: At the last update of this tutorial, Node.js 12.x is the LTS release available.
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
You can successfully add Node.js PPA to the Ubuntu system. Now execute the below command to install Node.js on and Ubuntu using apt-get. This will also install NPM with Node.js. This command also installs many other dependent packages on your system.
sudo apt-get install nodejs
After installing Node.js, verify and check the installed version. You can find more details about the current version on the Node.js official website.
node -v
v13.0.1
Also, check the npm version:
npm -v
6.12.0

Resources