1

I am trying to install nodejs on a newly built Ubuntu VM(Ubuntu 22.04.1 LTS), but getting the below error.

Preparing to unpack .../nodejs_16.19.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (16.19.1-deb-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_16.19.1-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.19.1-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Commands I used -

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

apt install nodejs

Running from root user.

1 Answer 1

0

There is a conflict between the Node.js package you want to install and the libnode-dev that is already on your computer.

Here is how to solve this problem: first remove the problematic package sudo apt-get remove libnode-dev then update all your packages sudo apt-get update then install Node.js the same way you did before

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

Now your Node.js should be working properly

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .