Skip to content

fix: embed node version requirement at compile time#1412

Open
liangmiQwQ wants to merge 1 commit intovoidzero-dev:mainfrom
liangmiQwQ:fix/embed-node-version-while-compiling
Open

fix: embed node version requirement at compile time#1412
liangmiQwQ wants to merge 1 commit intovoidzero-dev:mainfrom
liangmiQwQ:fix/embed-node-version-while-compiling

Conversation

@liangmiQwQ
Copy link
Copy Markdown
Contributor

@liangmiQwQ liangmiQwQ commented Apr 18, 2026

There is for an edge case about vp upgrade.

If you are using an incompatible node version and you run vp upgrade, it will not block your upgrading and install a broken vp cli (Node version outside the scope of engine.node would prevent package manager from downloading binary bindings)

Theoretically, the logic added in #1360 should resolve this problem, but as the code below, the node version is read at runtime not compile time.

async fn get_cli_engines_requirement(&self) -> Option<String> {
let cli_dir = self.get_cli_package_dir().ok()?;
let pkg_path = cli_dir.join("package.json");
let pkg = read_package_json(&pkg_path).await.ok()??;
pkg.engines?.node.map(|s| s.to_string())
}

As vp upgrade would delegate the cli installing task to the new downloaded vp binary, who has no valid package.json to read, it skips the node version's requirement check and causes this bug.


A solution is to inject the node version at compile time as a enhancement for #1360.

This PR simply used include_str!() to read package.json and the parsing is still at runtime. It is not the best way for performance. build.rs is required if we need even better runtime performance for it.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 18, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit aeac7e0
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69e2cafdc4cf2a0008203674

@liangmiQwQ
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@liangmiQwQ liangmiQwQ changed the title fix: embed node version requirement when compiling fix: embed node version requirement at compile time Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant