1

Trying to install NodeJS 16 on ubuntu 22.04.

Ran the official installation instructions:

sudo apt-get install -y nodejs

Got the following error:

The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/27.1 MB of archives.
After this operation, 128 MB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 218989 files and directories currently installed.)
Preparing to unpack .../nodejs_16.17.0-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (16.17.0-deb-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_16.17.0-deb-1nodesource1_amd64.deb (--unpack):
 trying to overwrite '/usr/include/node/common.gypi', which is also in package libnode-dev 12.22.9~dfsg-1ubuntu3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nodejs_16.17.0-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
tripleee
  • 175,061
  • 34
  • 275
  • 318
Omid Pirdehi
  • 21
  • 1
  • 5
  • Look like you are using MSI device? – HoangHieu Sep 13 '22 at 06:44
  • Remove your old libnode-dev package 12.22.9 first – CherryDT Sep 13 '22 at 06:47
  • The error message indicates a packaging error, probably then suggesting that you are in fact installing some third-party hack, not the real `nodejs` package from the official sources. Voting to close as lacking basic debugging details. – tripleee Sep 13 '22 at 06:48
  • Does this answer your question? [trying to overwrite \`/var/backups/infodir.bak', which is also in package x](https://stackoverflow.com/questions/15546064/trying-to-overwrite-var-backups-infodir-bak-which-is-also-in-package-x) – karel Sep 13 '22 at 07:12

1 Answers1

3

Various versions of Node.js are using a same file (one from apt install, one from manually download), which caused the conflict, resulting the error.

Remove your Node.js 12.22.9 first.

Geno Chen
  • 4,916
  • 6
  • 21
  • 39