Distributions: Cannot install Node 10 on Ubuntu 16.04

Created on 29 Aug 2018  ·  14Comments  ·  Source: nodesource/distributions

I'm running Node 8 from the NodeSource PPA on Ubuntu 16.04. Just attempted to upgrade to Node 10 by running this:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

But the system nodejs 4 is installed instead.

Running the Node 8 install instructions successfully installs Node 8:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

So it's just the Node 10 script that seems broken. What additional info can I provide to help debug this?

Most helpful comment

@chrislea I think I did the upgrade several years ago without issue. The OS and kernel were upgraded to 64-bit while dpkg stayed at 32-bit so all packages were 32-bit and that's probably why I haven't faced issues before.

If there's no better solution, I'll just rebuild the system I suppose.

All 14 comments

Hm, that's really odd. Those two scripts are identical except for the version numbers. If you could run the 10.x setup script and then show the output of:

apt-cache policy nodejs

that would be interesting. Alternatively, if you just want to make things work, something like this:

sudo sed -i "s|8\.x|10\.x|g" /etc/apt/sources.list.d/nodesource.list
sudo apt update
sudo apt upgrade

should do it.

The output from apt-cache policy nodejs after running the 10.x setup script is:

nodejs:
  Installed: 8.11.4-1nodesource1
  Candidate: 8.11.4-1nodesource1
  Version table:
 *** 8.11.4-1nodesource1 100
        100 /var/lib/dpkg/status
     4.2.6~dfsg-1ubuntu4.2 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages
     4.2.6~dfsg-1ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/universe i386 Packages

And this just made me realize that my intial report was slightly incorrect.

Running the Node 10 install script actually kept Node 8 installed. I had to run remove nodejs first, then install it before Node 4 was installed. Like this:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get remove -y nodejs
sudo apt-get install -y nodejs
nodejs -v # prints "v4.2.6"

Any ideas?

Can you cut and paste the full output (including the invocation command) of the 10.x installer script here? Also, can you show the output of:

cat /etc/apt/sources.list.d/nodesource.list

Sure, here you go:

$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

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


## Populating apt-get cache...

+ apt-get update
Hit:1 http://apt-longview.linode.com xenial InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease                           
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Hit:4 https://deb.nodesource.com/node_8.x xenial InRelease                          
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]          
Hit:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease                           
Fetched 216 kB in 1s (187 kB/s)                                                     
Reading package lists... Done

## Confirming "xenial" is supported...

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

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

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK

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

+ echo 'deb https://deb.nodesource.com/node_10.x xenial main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_10.x xenial main' >> /etc/apt/sources.list.d/nodesource.list

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

+ apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://apt-longview.linode.com xenial InRelease
Get:3 https://deb.nodesource.com/node_10.x xenial InRelease [4,611 B]   
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]                          
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]          
Hit:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease                           
Fetched 221 kB in 0s (222 kB/s)                                                     
Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 10.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 | sudo apt-key add -
     echo "deb 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
$ cat /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_10.x xenial main
deb-src https://deb.nodesource.com/node_10.x xenial main

And after that, running apt-cache policy nodejs shows this:

$ apt-cache policy nodejs
nodejs:
  Installed: 8.11.4-1nodesource1
  Candidate: 8.11.4-1nodesource1
  Version table:
 *** 8.11.4-1nodesource1 100
        100 /var/lib/dpkg/status
     4.2.6~dfsg-1ubuntu4.2 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages
     4.2.6~dfsg-1ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/universe i386 Packages

Oh, wait, sorry. I didn't completely read the output of the apt-cache policy command the first time.

The issue is that you're using a 32bit machine, and there aren't 32bit builds for 10.x and greater anymore. If you use a 64bit machine, you'll find supported packages. Otherwise, you'll need to compile Node from source for your 32bit machine.

If you want to read up more about why there aren't 32bit builds, there's a novel full of info in this issue. Hope this helps!

Sorry, I should mabe be a bit more specific. There aren't builds for 10.x and greater for 32bit Intel chips. There are still armhf builds that are 32bit for ARM chips because Raspberry Pis are very much a thing.

I believe I'm running a 64-bit machine. See this:

$ uname -i
x86_64
$ uname -a
Linux future 4.17.8-x86_64-linode110 #1 SMP PREEMPT Wed Jul 18 14:33:54 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Any idea why 32-bit Node is being installed?

Ah. Well, that is more interesting. And no, I don't immediately know why it would try and install the 32bit version. You might want to consult the Multiarch HOWTO.

If you just want to make it work, I'd try modifying /etc/apt/sources.list.d/nodesource.list so it looks like this:

deb [arch=amd64] https://deb.nodesource.com/node_10.x bionic main
deb-src https://deb.nodesource.com/node_10.x bionic main

and then running

sudo apt update
sudo apt install nodejs

again. I believe this should override whatever weird thing is going on with dpkg that's making it try and default to i386. Reopening so until this is resolved.

I modified /etc/apt/sources.list.d/nodesource.list as you recommended and it still wants to install Node 8:

$ apt-cache policy nodejs 
nodejs:
  Installed: 8.11.4-1nodesource1
  Candidate: 8.11.4-1nodesource1
  Version table:
 *** 8.11.4-1nodesource1 100
        100 /var/lib/dpkg/status
     8.10.0~dfsg-2ubuntu0.2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages
     8.10.0~dfsg-2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe i386 Packages

However, I think I realized the problem. This system was upgraded from 32-bit. Check this:

$ dpkg --print-architecture
i386

However, I can manually add amd64 as an alternate architecture:

$ dpkg --add-architecture amd64
$ dpkg --print-foreign-architectures
amd64

However, that still doesn't make Node 10 the default candidate to install:

$ apt-cache policy nodejs 
nodejs:
  Installed: 8.11.4-1nodesource1
  Candidate: 8.11.4-1nodesource1
  Version table:
 *** 8.11.4-1nodesource1 100
        100 /var/lib/dpkg/status
     8.10.0~dfsg-2ubuntu0.2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages
     8.10.0~dfsg-2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe i386 Packages

However, I can refer to it as nodejs:amd64 and it finds the right Node version. Finally!

$ apt-cache policy nodejs:amd64
nodejs:amd64:
  Installed: (none)
  Candidate: 10.9.0-1nodesource1
  Version table:
     10.9.0-1nodesource1 500
        500 https://deb.nodesource.com/node_10.x bionic/main amd64 Packages
     8.10.0~dfsg-2ubuntu0.2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
     8.10.0~dfsg-2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

But installing nodejs:amd64 still fails because the python-minimal:amd64 dependency cannot be installed. Presumably, the 32-bit version is already installed.

$ sudo apt install nodejs:amd64
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nodejs:amd64 : Depends: python-minimal:amd64 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Running out of ideas at this point. I suppose I need to rebuild the system from scratch?

Well, that would certainly explain it. Upgrading from a 32bit system to a 64bit on in-place like that... that's just not something you'd ever do on a box you expect to work correctly. I see you're just using a VPS from Linode, is there any reason to not just nuke it and then set up a fresh 64bit one? I sincerely doubt this is the last problem related that that upgrade you're going to run into.

@chrislea I think I did the upgrade several years ago without issue. The OS and kernel were upgraded to 64-bit while dpkg stayed at 32-bit so all packages were 32-bit and that's probably why I haven't faced issues before.

If there's no better solution, I'll just rebuild the system I suppose.

You might want to try something like:

sudo apt-get --reinstall install python-minimal:amd64

to see if that will make apt overwrite your 32bit python with the 64bit package. But I'd still argue that you're probably going to be in better shape if you just install a 64bit system fresh.

I'm going to close this since we know what the issues are, but just open it back up again if there's more I can do to help. Good luck!

I faced the same issue on the same host for doing the same i386 -> amd64 architecture upgrade. For what it's worth, I was able to get a working Node installation using:

sudo apt-get remove python-minimal
sudo apt-get install python-minimal:amd64
sudo apt-get install nodejs:amd64

(sudo apt-get --reinstall install python-minimal:amd64 did not work and complained about an impossible situation)

That said, I was concurrently building a new machine and moving stuff over, and that was done faster 🤷‍♂️.

Another useful info.
I have previously installed python-zsi, this package install python-minimal, and, this prevent to install node versions > =10. Node versions >= 10 require python2-minimal. I know, because I downloaded the deb file from https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/, and, when I run: sudo dpkg -i nodejs_10.21.0-deb-1nodesource1_amd64.deb throws an error, node is installed, but, nodejs can't be installed, python2-minimal is required. After I removed python-minimal, and use curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - everythink works fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichaelBitard picture MichaelBitard  ·  4Comments

SilkAndSlug picture SilkAndSlug  ·  5Comments

xNarkon picture xNarkon  ·  3Comments

wolfitis picture wolfitis  ·  4Comments

AJCStriker picture AJCStriker  ·  5Comments