You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22中升级Node.js失败,请求解决方法

Node.js升级报错解决方案

当前环境

Node.js版本:

nodejs -v
v12.22.9

尝试的升级命令

sudo apt remove nodejs
sudo apt install nodejs

出现的错误信息

(Reading database ... 220599 files and directories currently installed.)
Preparing to unpack .../nodejs_21.6.1-1nodesource1_amd64.deb ...
Unpacking nodejs (21.6.1-1nodesource1) ...

dpkg: error processing archive /var/cache/apt/archives/nodejs_21.6.1-1nodesource1_amd64.deb (--unpack):
trying to overwrite '/usr/include/node/common.gypi', which is also in package libnode-dev 12.22.9~dfsg-1ubuntu3.3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_21.6.1-1nodesource1_amd64.deb

解决步骤

  • 彻底移除旧版本及关联开发包
    sudo apt purge nodejs libnode-dev
    
  • 清理APT缓存并移除无用依赖
    sudo apt autoremove && sudo apt clean
    
  • 重新安装Node.js
    sudo apt install nodejs
    
  • 验证升级结果
    nodejs -v
    

内容的提问来源于stack exchange,提问作者python3.789

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 00:43:11