news 2026/6/10 15:18:05

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/6/10 15:16:43

Kotaemon供应链信息查询:物流状态即时反馈

Kotaemon供应链信息查询:物流状态即时反馈 在电商与物流高度融合的今天,客户早已不再满足于“您的包裹已发出”这样的静态通知。他们希望知道——我的快递现在在哪?是不是被延误了?还能不能今天送达?面对这些实时、动态…

作者头像 李华
网站建设 2026/6/9 21:08:13

47、CD与DVD的使用全攻略

CD与DVD的使用全攻略 插入CD或DVD后的情况及操作 当你插入一张CD时,可能会出现以下几种情况: - 自动启动安装程序 :如果插入的CD包含程序,安装程序会自动启动,你只需按照屏幕上的提示完成程序安装。 - 弹出操作对话框 :可能会弹出一个对话框,询问你接下来要执行…

作者头像 李华
网站建设 2026/6/10 15:15:32

python-flask-django西安工商学院学生请假管理系统_s4hrg6g5

文章目录系统截图项目技术简介可行性分析主要运用技术介绍核心代码参考示例结论源码lw获取/同行可拿货,招校园代理 :文章底部获取博主联系方式!系统截图 python-flask-django_shrg6g5 西安工商学院学生请假管理系统 项目技术简介 Python版本&…

作者头像 李华
网站建设 2026/6/10 14:11:53

Android滚轮选择控件终极指南:从入门到精通

Android滚轮选择控件终极指南:从入门到精通 【免费下载链接】WheelView Android滚轮控件,基于ListView实现,可以自定义样式。 项目地址: https://gitcode.com/gh_mirrors/whe/WheelView Android WheelView高性能滚轮控件,为…

作者头像 李华
网站建设 2026/6/10 13:57:03

Adobe Illustrator效率革命:5大核心脚本让你的设计工作提速300%

Adobe Illustrator效率革命:5大核心脚本让你的设计工作提速300% 【免费下载链接】illustrator-scripts Some powerfull JSX scripts for extending Adobe Illustrator 项目地址: https://gitcode.com/gh_mirrors/ill/illustrator-scripts 还在为繁琐的Illust…

作者头像 李华
网站建设 2026/6/9 20:53:34

30、Linux 系统下的音频处理全攻略

Linux 系统下的音频处理全攻略 在 Linux 系统中,音频处理涵盖了录制、播放、编辑等多个方面,涉及众多实用工具。下面将详细介绍这些工具及其使用方法。 音频录制 在 Linux 系统里,借助 rec 工具(它属于 sox 工具包),能够实现音频录制功能。 设置采样大小 :若要进…

作者头像 李华