我正在尝试在新建的 Ubuntu VM(Ubuntu 22.04.1 LTS)上安装 nodejs,但出现以下错误。
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)
我使用的命令 -
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt install nodejs
以 root 用户身份运行。
答案1
Node.js
您要安装的软件包和libnode-dev
计算机上已有的软件包之间存在冲突。
解决此问题的方法如下:首先删除有问题的软件包,sudo apt-get remove libnode-dev
然后更新所有软件包,然后按照之前的方式sudo apt-get update
安装Node.js
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
现在你Node.js
应该可以正常工作了