Trying to upgrade nodejs on ubuntu 20.10.

Ran the official installation instructions:

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

Got the following error:

The following packages will be upgraded:
1 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
1 not fully installed or removed.
Need to get 0 B/24.5 MB of archives.
After this operation, 119 MB of additional disk space will be used.
(Reading database ... 277425 files and directories currently installed.)
Preparing to unpack .../nodejs_14.15.4-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (14.15.4-deb-1nodesource1) over (12.18.2~dfsg-1ubuntu2) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_14.15.4-deb-1nodesource1_amd64.deb (--unpack):
 trying to overwrite '/usr/share/doc/nodejs/api/dgram.json.gz', which is also in package nodejs-doc 12.18.2~dfsg-1ubuntu2
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've looked at other StackOverflow answers recommending that I either try to uninstall nodejs-doc (the conflicting dependency) or to run the following command:

sudo dpkg -i --force-overwrite /usr/share/doc/nodejs/api/dgram.json.gz

Neither seemed to work. In the case of the above command, it said that the file needed to be a deb package - and anyway, I'm a little skeptical about that strategy as it could break my setup.

For attempting to removing nodejs-doc, I got the following output:

You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 nodejs : Depends: libnode72 (= 12.18.2~dfsg-1ubuntu2) but it is not going to be installed
          Recommends: nodejs-doc but it is not going to be installed

I've also tried running the recommended apt --fix-broken install but it doesn't seem to help.

  • Just a heads up: curl ... | sudo bash - is terrible from a security perspective. You run code as root without having a chance to review it. Unfortunately, this is becoming more and more common. – Panki Jan 5 at 14:53

You need to enable the universe repository which provide the missing dependencies libnode72 (= 12.18.2~dfsg-1ubuntu2) and nodejs-doc (12.18.2~dfsg-1ubuntu2) in Ubuntu 20.10 :

sudo add-apt-repository universe
sudo apt install libnode72 nodejs-doc

dpkg -i --force-overwrite should point to the .deb file:

sudo dpkg -i --force-overwrite  /var/cache/apt/archives/nodejs_14.15.4-deb-1nodesource1_amd64.deb

Just delete nodejs-doc:

sudo apt remove nodejs-doc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.