Unable to install NodeJS 14.x from NodeJS repo, Ubuntu's version 18.x is always installed

Bug #2001928 reported by Jaromir Obr
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nodejs (Ubuntu)
New
Undecided
Unassigned

Bug Description

It started after upgrade 22.04 => 22.10

Suppose no NodeJS version is installed (and no external NodeJS repo is saved in /etc/apt)
-------------------
$ node --version
Command 'node' not found, but can be installed with:
sudo apt install nodejs
------------------

Install NodeJS 14.x: https://github.com/nodesource/distributions/blob/master/README.md#using-ubuntu-3

You can see that NodeJS 18.x instead of NodeJS 14.x will be installed:
-----------------------
$ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

## Installing the NodeSource Node.js 14.x repo...

## Populating apt-get cache...

+ apt-get update
Hit:1 http://cz.archive.ubuntu.com/ubuntu kinetic InRelease
Hit:2 http://cz.archive.ubuntu.com/ubuntu kinetic-updates InRelease
Hit:3 http://cz.archive.ubuntu.com/ubuntu kinetic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu kinetic-security InRelease
Hit:5 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:6 https://repo.skype.com/deb stable InRelease
Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:8 https://packages.microsoft.com/repos/edge stable InRelease
Reading package lists... Done

## Confirming "kinetic" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_14.x/dists/kinetic/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
gpg: WARNING: unsafe ownership on homedir '/home/mirao/.gnupg'

## Creating apt sources list file for the NodeSource Node.js 14.x repo...

+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x kinetic main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x kinetic main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Hit:1 http://cz.archive.ubuntu.com/ubuntu kinetic InRelease
Hit:2 http://cz.archive.ubuntu.com/ubuntu kinetic-updates InRelease
Hit:3 http://cz.archive.ubuntu.com/ubuntu kinetic-backports InRelease
Hit:4 https://repo.skype.com/deb stable InRelease
Hit:5 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:6 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:7 https://packages.microsoft.com/repos/edge stable InRelease
Hit:8 http://security.ubuntu.com/ubuntu kinetic-security InRelease
Get:9 https://deb.nodesource.com/node_14.x kinetic InRelease [4,585 B]
Get:10 https://deb.nodesource.com/node_14.x kinetic/main amd64 Packages [773 B]
Fetched 5,358 B in 1s (3,683 B/s)
Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  npm
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 0 B/283 kB of archives.
After this operation, 1,937 kB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 236355 files and directories currently installed.)
Preparing to unpack .../nodejs_18.7.0+dfsg-5ubuntu1_amd64.deb ...
Unpacking nodejs (18.7.0+dfsg-5ubuntu1) ...
Setting up nodejs (18.7.0+dfsg-5ubuntu1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for man-db (2.10.2-2) ...
--------------------------------------------

$ node --version
v18.7.0

Revision history for this message
Jaromir Obr (jaromir-obr) wrote :

Workaround - use the "n" tool for switching to another NodeJS version:
$ sudo npm install -g n
$ sudo n 14

no longer affects: ubuntu
Revision history for this message
kapouer (kapouer) wrote : Re: [Bug 2001928] Re: Unable to install NodeJS 14.x from NodeJS repo, Ubuntu's version 18.x is always installed
Download full text (5.3 KiB)

Le jeu. 5 janv. 2023 à 15:20, Jaromir Obr <email address hidden> a
écrit :

> Workaround - use the "n" tool for switching to another NodeJS version:
> $ sudo npm install -g n
> $ sudo n 14
>
> ** Also affects: nodejs (Ubuntu)
> Importance: Undecided
> Status: New
>
> ** No longer affects: ubuntu
>
> --
> You received this bug notification because you are subscribed to Ubuntu.
> https://bugs.launchpad.net/bugs/2001928
>
> Title:
> Unable to install NodeJS 14.x from NodeJS repo, Ubuntu's version 18.x
> is always installed
>
> Status in nodejs package in Ubuntu:
> New
>
> Bug description:
> It started after upgrade 22.04 => 22.10
>
> Suppose no NodeJS version is installed (and no external NodeJS repo is
> saved in /etc/apt)
> -------------------
> $ node --version
> Command 'node' not found, but can be installed with:
> sudo apt install nodejs
> ------------------
>
> Install NodeJS 14.x:
> https://github.com/nodesource/distributions/blob/master/README.md#using-
> ubuntu-3
>
> You can see that NodeJS 18.x instead of NodeJS 14.x will be installed:
> -----------------------
> $ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
> sudo apt-get install -y nodejs
>
> ## Installing the NodeSource Node.js 14.x repo...
>
>
> ## Populating apt-get cache...
>
> + apt-get update
> Hit:1 http://cz.archive.ubuntu.com/ubuntu kinetic InRelease
> Hit:2 http://cz.archive.ubuntu.com/ubuntu kinetic-updates InRelease
>
> Hit:3 http://cz.archive.ubuntu.com/ubuntu kinetic-backports InRelease
>
> Hit:4 http://security.ubuntu.com/ubuntu kinetic-security InRelease
>
> Hit:5 https://download.docker.com/linux/ubuntu jammy InRelease
>
> Hit:6 https://repo.skype.com/deb stable InRelease
>
> Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease
>
> Hit:8 https://packages.microsoft.com/repos/edge stable InRelease
>
> Reading package lists... Done
>
> ## Confirming "kinetic" is supported...
>
> + curl -sLf -o /dev/null
> 'https://deb.nodesource.com/node_14.x/dists/kinetic/Release'
>
> ## Adding the NodeSource signing key to your keyring...
>
> + curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg
> --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
> gpg: WARNING: unsafe ownership on homedir '/home/mirao/.gnupg'
>
> ## Creating apt sources list file for the NodeSource Node.js 14.x
> repo...
>
> + echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg]
> https://deb.nodesource.com/node_14.x kinetic main' >
> /etc/apt/sources.list.d/nodesource.list
> + echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg]
> https://deb.nodesource.com/node_14.x kinetic main' >>
> /etc/apt/sources.list.d/nodesource.list
>
> ## Running `apt-get update` for you...
>
> + apt-get update
> Hit:1 http://cz.archive.ubuntu.com/ubuntu kinetic InRelease
> Hit:2 http://cz.archive.ubuntu.com/ubuntu kinetic-updates InRelease
>
> Hit:3 http://cz.archive.ubuntu.com/ubuntu kinetic-backports InRelease
>
> Hit:4 https://repo.skype.com/deb stable InRelease
>
> Hit:5 https://download.docker.com/linux/ubuntu jammy InRelease
>
> Hit:6 https://dl.googl...

Read more...

Revision history for this message
Jaromir Obr (jaromir-obr) wrote :

Well, "sudo apt install nodejs=14.21.1-deb-1nodesource1" really works.
But it's not permanent solution because if you perform "sudo apt update && sudo apt upgrade", then NodeJS is replaced by version 18.x

I would say that Ubuntu 22.10 has different order of resolving of repos than 22.04 when one package is in multiple repos (14.x in external repo vs. 18.x in internal repo).

>
> Mind that it may break your system - lots of other debian packages are
> depending on the version provided in debian.
> If you really want a given version, use containers, or even simpler, a
> nodejs binary release tarball.

I see, but I don't remember it was ever an issue for me in previous Ubuntu versions to switch between various NodeJS versions (the tools such as "nvm" or "n" provide such switching).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.