global update silently drops a platform-specific optional dependency

Đang mở
#10,173 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
backend, cli

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
JavaScript
Star
10.3k
Fork
5k
Merge trung bình
4 ngày 11 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của npm/cli

Tất cả issue của npm/cli

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.