How to upgrade node.js from 0.12 version to 4.0 version on Windows and Ubuntu - node.js

I already have installed Node.js v0.12.2 on Windows and Node.js v0.12.4 on Ubuntu 14.04 LTS. Can I just run the latest installer to upgrade it to v4.0.0 on Windows and run sudo apt-get update on Ubuntu?

Windows has an installer available at https://nodejs.org/en/download/
For Ubuntu, the official instructions are
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Find where node is
which node
Replace it with
sudo ln -sf /usr/bin/nodejs /path/you/find/node

Maybe for future use on Windows, you can take a look at nvmw. Very easy to use and without manually modifying your configuration. When things break, you can just as easily switch back to older versions.
Similar package for Ubuntu: nvm

Related

how to install a latest version of Nodejs on Ubuntu?

I start using ubuntu (22.04.1) recently. I want to install nodejs latest version (currently v18.12.1 LTS).
But my node --version showing version v12.22.9.
First I install node using sudo apt-get install nodejs. Then I re-install my node but before re-install I update my system using sudo apt update && sudo apt upgrade. But i keep getting same result. node version v12.22.9.
1-Install CURL if you don't have:
sudo apt-get install curl
2-Run the following command to add the PPA to the Ubuntu system:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
3-After successfully adding the PPA to the system, execute the command below to install Node on Ubuntu:
sudo apt-get install nodejs
4-check the version number of the installed software for node :
node -v
Don't use the distribution's default, Ubuntu is extremely conservative with bumping versions of things like Node, so instead go with Node's repository.
The current location is documented in the installer instructions:
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
Where the setup_ scripts usually do a good job of getting everything properly sorted.
For the 18 LTS version:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
I would use nvm - Node Version Manager, see https://github.com/nvm-sh/nvm#install--update-script
This has a couple of advantages: you don't change the system's node version (which might be used elsewhere) and you may select a distinct (older or newer) version of node accompanied by appropriate installations of npm, yarn, a.s.o. It's simple to install "global" packages just locally (kind of oxymoron...) for your user. You don't need root permission for these.

How to install nodejs 6.7.0 on Ubuntu 14

I have found some guides (for ex. Install latest nodejs version in ubuntu 14.04) how to install updated version of NodeJS, also followed the official one that says to use
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
which is the same thing as in the SO guide above.
However, the version of node I get is 6.3.1 but I want the latest 6.7.0. I have installed 6.7.0 on OSX via brew but don't know how to get it on Ubuntu. Is there any way to do it, using APT preferably?
I have done this way:-
sudo npm install n -g
sudo n 6.7.0
Alternatively for latest stable version you can do this:-
sudo n stable
And For latest version
sudo n latest

How to install latest node version on Ubuntu?

I want to install the latest node (v6.2.0 at the time of writing) on Ubuntu. But as I do
sudo apt-get nodejs
This installed v0.10.37.
Can you please help me in installing the latest version of node js and also npm latest version?
This is very simple,
Grab the Linux node distribution from here:
https://nodejs.org/dist/v6.2.0/
Open Terminal and type below command:
sudo tar -C /usr/local --strip-components 1 -xzf ~/Downloads/node-v6.2.0-linux-x64.tar.gz
ls -l /usr/local/bin/node
That`s it.
Now check your node version by typing:
node -v
npm -v
One can install any version of node in Ubuntu using above steps.
There is official instruction:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Follow https://deb.nodesource.com/setup_6.x to read shell script before execute above commands.
You always must to know what you run, especially by sudo.
Any version of node install is very easy
Just click Node.js scroll down and go Installation instructions and chose which version you want to install
To Install 12.x version of node:
Open your terminal [Ctrl+Alt+t]
execute below command
Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
or
Using Debian, as root
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs
To remove previous version use command
sudo npm cache clean -f
sudo npm install -g n
and then for latest version
sudo n latest
Or for stable version
sudo n stable
By far the most convenient way to install and manage node versions on your machine is the Node Version Manager a.k.a nvm. Just follow the installation instructions in the repo and after you have it installed run
nvm install 6.2.0
I would suggest installing through package manager to make sure it installs with accurate dependencies.
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
Also, use NPM
sudo apt-get install npm
to install modules, like so:
npm install express
Install the package through the official download page, in a .deb format. Go ahead and grab the newest version here:
https://nodejs.org/download/release/latest/
Just go ahead and download your desired version and double-click on the downloaded .deb file, and you're good to go. npm comes with nodejs, btw.
RECOMMENDED READING
https://www.npmjs.com/package/npm
EDIT
If you wish to completely reinstall nodejs, check out the script located here:
https://gist.github.com/brock/5b1b70590e1171c4ab54
and check out this:
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
It says Mac OSX, but it'll work perfectly fine in ubuntu, too.
depends on what version of latest nodejs you want to install
if LTS version or current latest version, then from PPA
latest LTS version
apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
apt-get install nodejs
current latest version
apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt-get install nodejs
source: https://codesposts.com/ydOAwynW
Install the snap package
The easiest method to install Node.js on Ubuntu is to use the snap package. Just search for node on Ubuntu Software store and install the first one.
Or if you prefer command line:
sudo snap install node --classic
Alternate method: NVM
If you can't use snaps for some reason, like from a WSL environment, then Node Version Manager (NVM) is the way to go. It's safer than upgrading the node packages in Ubuntu to unsupported versions from PPAs or 3rd party repos, which may cause conflicts or breakages in apt package management system. Compared to NVM, manual installations from tarballs are harder to maintain and upgrade. Follow these steps to install the latest node using NVM:
Step 1: Install NVM
Run this command in Terminal:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Step 2: Install node
Once NVM installation is complete, close and reopen Terminal. Then run this command:
nvm install node
Step 3: Check node version
Run these commands:
node --version
npm --version
If everything went well, you'll see the latest node and npm versions as output. That's all, node is installed and ready to run! 😊
Note: This question is similar to the AskUbuntu question "How do I install the latest version of node.js?" and my answer equally applies. I'm reproducing my answer here to ensure a full complete answer exists rather than just a link.
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y nano git curl vim htop gnupg2 && curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - && sudo apt-get install -y nodejs
Install NodeJS 14x and npm 7x in Ubuntu 2020 LTS
Install Nodesource: curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Install NodeJS: sudo apt-get install -y nodejs
Install latest npm: npm install -g npm#latest
For certain npm packages to run: sudo apt install build-essential
The easiest way is using a single line command is sudo snap install node --classic
It installs the latest stable node version from snap store.

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.

Why do I get old versions of nodejs and npm when installing with apt-get?

I have executed the following command in Ubuntu 14.04 64-bit.
sudo apt-get update
sudo apt-get install nodejs modejs-legacy npm
I have the versions
npm -v
1.3.10
nodejs -v
v0.10.25
These are older than the recommended versions for AngularJS 2.
Why does apt-get download old version?
How do I update to newer versions?
Debian/Ubuntu has old version in their package manager, you have to use custom PPA repository as stated here:
https://github.com/nodesource/distributions/blob/master/README.md#debinstall
Setup it with:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
Then install with Ubuntu:
sudo apt-get install --yes nodejs
To get the latest version the easiest thing to do is install nvm. nvm install instructions
install nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
nvm install v10.15.3
(optional) set default nvm alias default v10.15.3

Resources