This error occurred while installing nodejs

I am trying to install nodejs but facing this error while installing.
I got the same error,
Preparing to unpack .../nodejs_18.15.0-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (18.15.0-deb-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_18.15.0-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_18.15.0-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
but this is the exact error,
trying to overwrite '/usr/share/systemtap/tapset/node.stp', which is also in package libnode72:amd64 12.22.9~dfsg-1ubuntu3
In my case removed the libnode72 package by running the following command.
sudo apt remove libnode72
# If above does not work for you, run below commands
sudo dpkg --remove --force-remove-reinstreq libnode-dev
sudo dpkg --remove --force-remove-reinstreq libnode72:amd64
I think in your case you have to remove the libnode-dev package. Please try it by running the following command,
sudo apt remove libnode-dev
If this doesn't work for you or anyone, please add a comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With