Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Package.json script tasks don't expose npm lifecycle env; cache-enabled tasks strip host-stamped values

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

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
65/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ệ
nodejs, rust
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Bắt đầu trong vt_plan tại plan_spawn_execution và kiểm tra EnvFingerprints::resolve, DEFAULT_UNTRACKED_ENV cùng phần chèn MARKER_ENV_NAME hiện có. Sau đó đọc toàn bộ fixture end-to-end của vp_run_env, bao gồm cả trường hợp được cache. Hoàn thành có nghĩa là các tác vụ trong package.json vẫn giữ môi trường vòng đời npm liên quan, bao gồm cả các tác vụ bật cache, với coverage cho hành vi đã được báo cáo.

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

Mô tả

Summary

When vite-task spawns a package.json script, the child gets none of the npm lifecycle environment variables (npm_execpath, npm_config_user_agent, npm_lifecycle_event, npm_node_execpath, …) that npm, pnpm, and Yarn all set when they run scripts. Tools that detect their invoking package manager from that env — npm-run-all2/run-p being the common one — silently fall back to npm, which then fails devEngines.packageManager enforcement in pnpm projects.

Downstream report: voidzero-dev/vite-plus#2317 (vpr checkrun-p → npm → EBADDEVENGINES). Reproduced there with a minimal project: pnpm run check sets npm_execpath=<pnpm>/bin/pnpm.mjs, npm_config_user_agent=pnpm/11.20.0 …, npm_lifecycle_event=probe for the child; the same script through the task runner gets none of them.

Why a vite-plus-side fix can't fully cover it

voidzero-dev/vite-plus#2385 stamps npm_execpath / npm_config_user_agent / npm_node_execpath / INIT_CWD into the process env before Session::init snapshots it. That works for plain scripts (which default to cache: scripts: false), but two pieces need the planner:

  1. Cache-enabled tasks strip the stamped vars again. plan_spawn_execution runs EnvFingerprints::resolve(&mut spawn_envs, &cache_config.env_config) before spawning, and DEFAULT_UNTRACKED_ENV contains no lowercase npm_* name (matching is case-sensitive on Unix). So for cache: { scripts: true } or config-defined tasks (cached by default), the session-level stamp is filtered out and the npm fallback returns — only in the cached case, which no fixture currently exercises. The VP_RUN marker had this exact problem and is re-inserted after the filter, with a comment explaining why.
  2. npm_lifecycle_event / npm_lifecycle_script are per-task values (script name / script body). Only the planner knows them; a session-level stamp can't provide them. pnpm sets both for every script it runs.

Suggested direction

  • Re-insert the lifecycle names post-filter next to the existing MARKER_ENV_NAME insert in vt_plan (or add them to DEFAULT_UNTRACKED_ENV), so host-provided lifecycle env survives cache-enabled tasks.
  • Optionally set npm_lifecycle_event (and npm_lifecycle_script) from the task itself when spawning package.json scripts, which vite-plus cannot do from outside.

Happy to send a PR for either or both if the direction sounds right — the vp_run_env e2e fixture looks like the natural place for coverage (its cached case already demonstrates the marker surviving the env filter).

Ngôn ngữ chính
Rust
Star
466
Fork
42
Merge trung bình
1 ngày 20 giờ
Pull request đã merge (30 ngày)
21

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 voidzero-dev/vite-task

Tất cả issue của voidzero-dev/vite-task

Issue tương tự

Thêm issue về Rust

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.