I just installed Ubuntu 22.04 a few days ago. My laptop is almost entirely blank. So I am met with confusion when I try to install Nodejs using these DigitalOcean instructions and I get an error.
I do:
sudo apt update
sudo apt install nodejs
The second command gives
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
javascript-common libc-ares2 libjs-highlight.js libnode72
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 0 B/26.4 MB of archives.
After this operation, 124 MB of additional disk space will be used.
(Reading database ... 197872 files and directories currently installed.)
Preparing to unpack .../nodejs_16.15.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (16.15.1-deb-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_16.15.1-deb-1nodes
ource1_amd64.deb (--unpack):
trying to overwrite '/usr/share/systemtap/tapset/node.stp', which is also in pa
ckage libnode72:amd64 12.22.9~dfsg-1ubuntu3
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_16.15.1-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I am new to Ubuntu so I can't read this message, or at least I can't tell what's useful etc.
I found a similar error message using Google here and I followed this instruction on the page.
// Delete the new package source.
cd /etc/apt/sources.list.d
sudo rm nodesource.list
// Update apt, fix the install, remove nodeJS and the nodejs-doc packages.
sudo apt --fix-broken install
sudo apt update
sudo apt remove nodejs
sudo apt remove nodejs-doc
// then use the instructions to install the latest node
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
But that gives me the same or a similar error
sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
javascript-common libc-ares2 libjs-highlight.js libnode72
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 0 B/26.4 MB of archives.
After this operation, 124 MB of additional disk space will be used.
(Reading database ... 197872 files and directories currently installed.)
Preparing to unpack .../nodejs_16.15.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (16.15.1-deb-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_16.15.1-deb-1nodesource1_amd64.deb (--unpack):
trying to overwrite '/usr/share/systemtap/tapset/node.stp', which is also in package libnode72:amd64 12.22.9~dfsg-1ubuntu3
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_16.15.1-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Any suggestions? Please & thank you