Ubuntu24.04.3执行sudo apt install yarnpkg 命令失败的原因

安装yarnpkg:

sudo apt-get update

sudo apt install yarnpkg

安装成功。

执行命令:执行 yarnpkg --cwd vendor/adevtool/ install

报错:

error log-update@7.0.1: The engine "node" is incompatible with this module. Expected version ">=20". Got "18.19.1"

error Found incompatible module.

info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

那好吧,升级node到20以上,执行如下:

sudo apt update

sudo apt install curl

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

sudo apt install nodejs

验证安装:

node -v

v20.19.6

参考地址:https://comate.baidu.com/zh/page/dv43dn0ek14

好了,升级完了,再次执行yarnpkg --cwd

报错:

找不到命令 "yarnpkg",但可以通过以下软件包安装它:

sudo apt install yarnpkg

执行:sudo apt install yarnpkg

报错:

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

Some packages could not be installed. This may mean that you have

requested an impossible situation or if you are using the unstable

distribution that some required packages have not yet been created

or been moved out of Incoming.

The following information may help to resolve the situation:

The following packages have unmet dependencies:

yarnpkg : Depends: node-chalk but it is not going to be installed

Depends: node-cli-table but it is not going to be installed

Depends: node-debug but it is not going to be installed

Depends: node-deep-equal but it is not going to be installed

Depends: node-emoji but it is not going to be installed

Depends: node-imports-loader but it is not going to be installed

Depends: node-inquirer but it is not going to be installed

Depends: node-invariant but it is not going to be installed

Depends: node-js-yaml (>= 3.13.1) but it is not going to be installed

Depends: node-micromatch but it is not going to be installed

Depends: node-mkdirp (>= 1.0~) but it is not going to be installed

Depends: node-proper-lockfile but it is not going to be installed

Depends: node-puka but it is not going to be installed

Depends: node-request (>= 2.88.1-5~) but it is not going to be installed

Depends: node-request-capture-har but it is not going to be installed

Depends: node-rimraf but it is not going to be installed

Depends: node-semver but it is not going to be installed

Depends: node-strip-ansi but it is not going to be installed

Depends: node-yn but it is not going to be installed

Depends: nodejs:any

E: Unable to correct problems, you have held broken packages.

根据您提供的错误信息,sudo apt install yarnpkg 命令失败的原因是依赖项未满足。以下是解决方案:

  1. ‌更新包列表并修复依赖关系‌

sudo apt update

sudo apt install -f # 修复损坏的依赖关系

  1. ‌安装缺失的 Node.js 依赖‌

Yarn 依赖于 Node.js,但系统可能未安装或版本不兼容。建议使用 Node 版本管理器(如 nvm)安装 Node.js:

bash

安装 nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

source ~/.bashrc # 或 source ~/.zshrc

安装 Node.js(建议 LTS 版本)

nvm install --lts

验证安装版本:

node -v

v24.12.0

  1. ‌重新安装 Yarn‌

安装 Node.js 后,重新尝试安装 Yarn:

bash

sudo apt install yarnpkg (失败)

  1. ‌使用 npm 安装 Yarn(备选方案)‌

如果系统包管理器仍无法安装,可使用 npm 安装:

bash

npm install -g yarn

added 1 package in 2s (成功)

相关推荐
Evan芙2 小时前
搭建 LNMT 架构并配置 Tomcat 日志管理与自动备份
java·架构·tomcat
青云交2 小时前
Java 大视界 -- Java+Spark 构建企业级用户画像平台:从数据采集到标签输出全流程(437)
java·开发语言·spark·hbase 优化·企业级用户画像·标签计算·高并发查询
刘一说2 小时前
GeoServer:开源GIS服务器的技术深度解析与OGC标准实践
运维·服务器·开源
小魏的马仔2 小时前
【elementui】el-date-picker日期选择框,获取焦点后宽度增加问题调整
前端·vue.js·elementui
铉铉这波能秀2 小时前
正则表达式从入门到精通(字符串模式匹配)
java·数据库·python·sql·正则表达式·模式匹配·表格处理
JarvanMo2 小时前
想让你的 Flutter UI 更上一层楼吗?
前端
Promise4852 小时前
关于使用wsl实现linux移植(imux6ull)的网络问题
linux·服务器·网络
郝学胜-神的一滴2 小时前
Linux线程的共享资源与非共享资源详解
linux·服务器·开发语言·c++·程序人生·设计模式
郝学胜-神的一滴2 小时前
Linux进程与线程的区别:从内存三级映射角度深入解析
linux·服务器·c++·程序人生