global update silently drops a platform-specific optional dependency

未关闭
#10,173 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
backend, cli

调研方向

Start by tracing the global update path for npm install -g and how it handles aliased optionalDependencies; compare it with the local-install fix in issue #8645. The report gives a reproducible case with @openai/codex@latest on npm 11.18.0, where the platform package is missing after a successful update but returns after uninstalling and reinstalling. Identify the relevant tests for global updates and add coverage that verifies the platform dependency remains installed.

由索引模型根据 Issue 内容生成。

描述

Bug cmd:update config:global Priority 2

https://github.com/npm/cli/issues/8628#issuecomment-6076454666

Still seeing this (or a closely related variant) on npm 11.18.0 — a global update silently drops a platform-specific optional dependency and exits 0. Posting here since #8645 supposedly fixed the local-install case in 11.6.3/11.6.4; the global path still appears affected.

Environment

  • npm: 11.18.0
  • Node.js: v22.23.1
  • OS: Linux x86_64
  • prefix: ~/.npm-global (non-default, via npm config set prefix)

What happened

  1. @openai/codex was already installed globally at an older version.

  2. Ran npm install -g @openai/codex@latest (this is also what Codex's built-in updater runs). Output: changed 2 packages in 29s, exit code 0.

  3. @openai/[email protected] declares its platform binaries through aliased optionalDependencies:

    "optionalDependencies": {
      "@openai/codex-linux-x64": "npm:@openai/[email protected]",
      "@openai/codex-linux-arm64": "npm:@openai/[email protected]",
      ...
    }
    
  4. After the update, ~/.npm-global/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64 was missing entirely, so the package's CLI fails at runtime with:

    Error: Missing optional dependency @openai/codex-linux-x64.
    Reinstall Codex: npm install -g @openai/codex@latest
    

    A plain re-run of npm install -g @openai/codex@latest (as the error message suggests) does not fix it — it again reports success while leaving the optional dep out.

Workaround that worked

npm uninstall -g @openai/codex && npm install -g @openai/codex@latest

A full uninstall + reinstall restores @openai/codex-linux-x64 correctly.

Happy to run diagnostics (npm ls -g, arborist logs, etc.) if helpful.

主要语言
JavaScript
星标
10.3k
派生
5k
平均合并
4 天 11 小时
30 天内合并 PR
26

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

npm/cli 的其他 Issue

查看 npm/cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。