apt-get always installs old version of node.js - node.js

I want to install 11.x version of Node.js on my Ubuntu sevrer using apt/apt-get, but it always installs version 8.10.x. Is there a way to install the latest 12.x or 11.x version without using nvm?
I've tried apt-get update, purging nodejs, using commands below:
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
None of above helped. I'm still getting an old verion of Node.js

The implementations of languages provided by operating systems tend to lean towards stability within their particular ecosystem (i.e: they play nice with everything else in the repositories). If you wish to use a newer version I recommend asdf which allows you install multiple versions of implementations of various languages including Node.

Related

How to install Node.js version 16.x.x in a Debian based image (Dockerfile)? (why so hard?)

Date: Tuesday October 5th, 2021
Node 10.x was released on 2018-04-24 (but that's the default version when using apt-get)
I have needs to have both Python and Node.js installed in running container. I can get the latest version of python in a container using:
FROM python:alpine
or
FROM python:buster <== Debian based
How do I get the latest version of node.js (16.10.0) installed on Debian (in a Docker container)
Whe I do this:
FROM python:buster
RUN apt-get update && \
apt-get install -y \
nodejs npm
I get these versions of node:
node: 10.24.0
npm 5.8.0
and when run in the container give a long statement about no longer being unsupported.
What's up with the package repo that 'apt-get' pulls from, that it will not install later versions of node (14.x or greater)?
If I pull from:
FROM python:alpine
and include these lines
RUN apk -v --no-cache --update add \
nodejs-current npm
I will get node 16.x version, which makes it easy. I don't have to do anything else.
Is there something equivalent for python:buster (Debian based)
I would really like a one or two liner in my Dockerfile and not a pages of instructions with a dozen commands to simply get node in the image.
I would appreciate any tested/proven reply. I am sure a number of others have the same question. Other stackoverflow articles on this subject are convoluted and do not provide the simple solution I am hoping to find that is available with pytyon:alpine
There is a reason I need python:debian and cannot use python:alpine in this one use case, otherwise I would chose the latter.
Is there a way some how to get a package repo maintainers attention to show me how to get a recent version (14..16), into the apt-get repository?
It appears many people are having issues with this.
You can use:
FROM python:buster
RUN apt-get update && \
apt-get install -y \
nodejs npm
RUN curl -fsSL https://deb.nodesource.com/setup_current.x | bash - && \
apt-get install -y nodejs

Linux: How to install certain old version of a software via apt-get

I am trying to install the same versions of Apache, MySQL and PHP in my Linux PC (Raspberry Debian) as installed in my remote public server.
For instance, I'd like to install the last legacy release of the 2.2 branch, Apache/2.2.31.
apt-cache showpkg apache2
Output:
Package: apache2
Versions:
2.4.10-10+deb8u4 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_jessie_main_binary-armhf_Packages)
But there isn't any information about the 2.2.31 version, neither in "Reverse Provides" section. I can do it by compiling from the sources, but it takes a lot of time. And I tried to find a reliable PPA or a reliable sources for deb packages, without any success.
How can I do it?
If APT tracks the specific version you are looking for, (like Kyle said) then it's pretty easy.
sudo apt-get install <pkg_name>=<pkg_version>
or
sudo apt-get -t=<target_version> <pkg_name>
To see which packages are tracked, run
apt-cache showpkg <package_name>
Unfortunately though, if a particular version is not managed by the APT, then you are out of luck using APT. It might be managed by some of the other package managers out there.
Ref. How can I downgrade a package via apt-get?
If you have the version number, or the target release, apt-get supports choosing a particular version or target release. More details can be found on manual page of apt-get. It can also be accessed from a terminal by typing man apt-get.
sudo apt-get install <package-name>=<package-version-number>
or
sudo apt-get -t=<target release> install <package-name>

confused: Why which Version Node.JS

I have been trying to get Gulp.js to work for 3 days and have failed so far. I have now resorted to reinstalling Linux Mint 17.3 from scratch... I want to install Node.JS on my machine and then run Gulp.
On nodejs.org https://nodejs.org/en/download/package-manager/it says:
two versions:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
and then
sudo apt-get install -y nodejs
How can I know which version to install? For running Gulp cli which is the best way forward?
On many sites I read "do not use apt-get to install Node.JS" They never mention a reason. Apparently, it is better to use NVM (??)
So, can anyone explain it to me? Which version do I install? setup_4? setup_6? Which way to install Node.JS is the best way? apt-get or NVM? and especially WHY?
Thanx,
Thom
do not use apt-get to install Node.JS
In the past the distro packaging was ~~not so good~~ really bad and created problems. Also it was notoriously late in regards of the latest node version available. I m not sure today about apt, but on my fedora 23 i m still getting provided node#0.10. So for me it s a no go.
Apparently, it is better to use NVM
Node Version Manager helps to get setup and running quickly. It also helps you to switch between old/new versions very very quickly. awesome tool for developers.
V4? V6?
Depends of your task and its goal.
For example, you are creating a build chain for front end development, you may go for v6 because only the developers will be impacted by this decision. Its a decision to take with the team.
If you work on a server api, you should choose one in agreement with your sysop team (or force them, depends your context).
You are working on packages to be distributed (cli), go for the LTS v4, it s going to be more stable.
You do not have constraints ? Go for v4 for stability, v6 for the latest features about es6 for example.
hth!!

Installed node.js ver 0.8 but node --version still shows previous version 0.6.12

I tried installing node ver 0.8 on my ubuntu 12.04.It already has a node ver 0.6.12.The installation went suceesfully but when i type in
node --version
it still shows previous version.
i tried to remove previous version using sudo apt-get remove node but it says package node is not installed.But on trying node --version it shows 0.6.12
Why is it so??
The problem is, you need to replace the new location for node with the old in your PATH variable. If you have an old manual install, find the old path to node by running echo $PATH. Then run this command:
export PATH=${PATH%$OLD_NODE_PATH/bin*}$NEW_NODE_PATH/bin${PATH#$*OLD_NODE_PATH/bin}
Or if you are using an install from the apt-get repository, just run:
export PATH=$NEW_NODE_PATH/bin
And that should fix your problem. But there is a better way! The best tool to manage your node.js environment is NVM. It exactly like RVM for ruby and similar to virtualenv for python, if you are familiar with those tools. It allows you to switch versions of node and download new ones extremely efficiently, and is easy to use. Download and install with:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
Then add this line to your bash (assuming you are running a bash shell) where it will be loaded (I prefer .bash_login for the personal stuff although it is not loaded by default):
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh
Source your bash script or restart the terminal then enter this command:
nvm install 0.8.0 && nvm use 0.8.0
This should set you up just fine. Although not necessary, you should probably get rid of all the other node installs, for the sake of tidiness. Check out their github page but to get you started here is a quick overview:
nvm ls # list all installed versions of node
nvm ls-remote # list all available versions of node
nvm install 0.9.8 # download and install node v0.9.8
nvm use 0.8.0 # switch current environment to use node v0.8.0
nvm alias default 0.8.0 # set 0.8.0 as default, you can use 'nvm use default'
nvm deactivate # use system install of node
nvm run default app.js # run app.js with default node version
I had this issue until I followd the directions on
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
which included running:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
first. Then running sudo apt-get install nodejs npm got me to 0.8.x
Also see: http://apptob.org/
Seem like you install nodejs package from Ubuntu repo and manually install node 0.8 after?
Try remove nodejs package.
The way to get a more recent version of Node.js is to add a PPA (personal package archive) maintained by NodeSource. This will probably have more up-to-date versions of Node.js than the official Ubuntu repositories.
First, you need to install the PPA in order to get access to its contents:
curl -sL https://deb.nodesource.com/setup | sudo bash -
The PPA will be added to your configuration and your local package cache will be updated automatically. After running the setup script from nodesource, you can install the Node.js package using the below command.
sudo apt-get install nodejs
You can check the node by using this command
node -v

Need Advice: Latest version of Node.js vs using Synaptic Package Manager?

I'm trying to get node.js and npm installed on my Ubuntu 11.10 installation, and I'm having a tricky time. I decided to go the route of downloading and compiling from the latest source because I want to use the new version of node.js - v0.6.0 instead of the older version that the synaptic package manager will install. However, I could not get npm set up correctly with it due to a "module not found" error. I was completely surprised at how little information I was able to find on the error.
Anyways, my goal here is to learn node.js, not to run a production environment. Should I give in and use v4.9 or is it really worth getting the newest version for the sake of learning, even if I have to go through the pain of keeping it updated and configuring it myself?
If you have Ubuntu, install it from Chris Lea's repo, it's always up to date with the last stable version (for ex now the version is 0.6.0 - as of today):
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
Generally, you want to install node from source since the packages you find in package managers are usually out of date. 0.4.12 was the last stable before 0.6.0 that was released a few days ago. 0.4.9 is pretty out of date.
This is a old question, nowadays my preferred way to install node is by using nvm (Node Version Manager). This will allow you to have multiple versions of node installed and quickly switch version.
Installation:
Install C++ compiler
apt-get update
apt-get install build-essential libssl-dev
Install NVM
curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
source ~/.profile
Install node (select which version you want to install)
nvm install 6
Usage:
To set a default node version:
nvm alias default 0.12.7
To select a different installed version:
nvm use 4

Resources