TransWikia.com

Can't install NodeJS with "The following packages have unmet dependencies" error

Raspberry Pi Asked by justanotherguy on October 5, 2021

My Raspberry Pi had NodeJS v 8 installed on it a while back and after running into some issues with Homebridge, I thought it was time for an update. Attempting to update NodeJS – and then completely remove and reinstall NodeJS – has lead me to this same dead end:

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 : Depends: libstdc++6 (>= 5.2) but 4.9.2-10+deb8u2 is to be installed
E: Unable to correct problems, you have held broken packages.

What can I do to correct this?

UPDATE:

The error was with trying to install the recommended release of NodeJS (which is v12 right now). I instead tried installing v10 and that worked fine without this issue. My guess is the Raspberry Pi OS itself just doesn’t support NodeJS 12+ yet. Surely there’s a way to download the correct packages, but I can’t figure that out on my own.

2 Answers

I already installed NodeJS a few times on Raspberry Pis but always used the packages from the NodeJS download page. The great advantage is that you don't have to compile anything, just download it and you're done.

The files on the NodeJS download page are always the newest LTS version. Right now it is v12.18.2 (07/21/2020)

First, you have to check what CPU architecture your Raspberry Pi is using: uname -m (ARMv7 and ARMv8 are supported)


Edit: Raspberry Pi 3B+ has an ARMv8 CPU but ARMv8 is disabled by default (+15% performance) and runs ARMv7 by default, so all newer Raspberry Pis are able to execute both 64-bit and 32-bit code. The best way to go, is to download the ARMv7 package of Node, as it will work 99.9% of the time.


You'll find the source code for your architecture on the download page (ARMv7 or ARMv8). Download it using wget <download-link>, extract it: tar -xzf <downloaded archive> and copy the extracted directory/files to the system path:

cd node-v12.18.2-linux-armv7l/
sudo cp -R * /usr/local/

Check if node and npm are correctly installed using node -v and npm -v

Correct answer by Fipsi on October 5, 2021

The error when installing Node.js v12 is a known issue in Debian 8 (Jessie). But it works correctly in Stretch or Buster.

As Jessie is not really supported anymore, it would be better to upgrade the OS. If that is no option for you, then Node.js v10 should indeed work fine.

Answered by user1650076 on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP