news 2026/4/18 11:23:06

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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 # 修复损坏的依赖关系

2. ‌安装缺失的 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

3. ‌重新安装 Yarn‌

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

bash
sudo apt install yarnpkg(失败)

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

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

bash
npm install -g yarn
added 1 package in 2s(成功)

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/17 7:26:30

51、Windows个性化设置全攻略

Windows个性化设置全攻略 在使用Windows系统时,个性化设置能让你的电脑使用体验更加舒适和高效。下面将详细介绍如何对Windows桌面和开始菜单进行个性化设置。 多用户账户设置说明 如果你的电脑有多个用户账户,那么本文所描述的所有设置仅适用于你当前登录的用户账户。因为…

作者头像 李华
网站建设 2026/4/18 7:42:39

网页转EPUB终极指南:如何将任意网页变成永久收藏的电子书

在信息爆炸的时代,我们每天都会遇到想要保存的精彩内容——一篇深度分析文章、一部连载小说或一个技术教程。但网页链接会失效,内容可能被删除,网络信号时好时坏。有没有一种方法,能把有价值的网页内容永久保存下来,随…

作者头像 李华
网站建设 2026/4/18 5:38:28

ONNX终极指南:彻底解决深度学习模型跨框架部署难题

ONNX终极指南:彻底解决深度学习模型跨框架部署难题 【免费下载链接】onnx Open standard for machine learning interoperability 项目地址: https://gitcode.com/gh_mirrors/onn/onnx 你是否曾为训练好的模型无法在其他框架中运行而苦恼?想象一下…

作者头像 李华
网站建设 2026/4/18 10:50:25

网易云音乐网页版高级功能探索:解锁更多实用技巧

网易云音乐网页版高级功能探索:解锁更多实用技巧 【免费下载链接】myuserscripts 油猴脚本:网易云音乐:云盘歌曲快传(含周杰伦),歌曲下载,转存云盘,云盘匹配纠正,听歌量打卡,本地上传云盘 咪咕音乐:歌曲下载 项目地址: https://gitcode.com/gh_mirrors/my/myusers…

作者头像 李华
网站建设 2026/4/18 8:18:10

20、精打细算工程师的防间谍软件指南

精打细算工程师的防间谍软件指南 在网络安全的大环境下,间谍软件和广告软件的传播是一个严峻的问题。为了有效防范这些恶意软件,我们可以从多个方面入手,采取一系列实用的措施。 弹出窗口拦截器设置 弹出窗口拦截器的过滤级别是可配置的。较高的过滤级别能拦截更多弹出窗…

作者头像 李华