Skip to content

fix: support pnpm 12 native binary when launching package manager - #722

Open
ivictbor wants to merge 1 commit into
mainfrom
fix/pnpm-12-native-bin
Open

ivictbor wants to merge 1 commit into
mainfrom
fix/pnpm-12-native-bin

Conversation

@ivictbor

@ivictbor ivictbor commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Task: AdminForth/1956

Problem

pnpm 12 (released 2026-08-26) no longer ships a JS entrypoint. Its bin.pnpm now points to a native executable that install.js drops into the package root from @pnpm/exe.<platform>; pnpm 11 and earlier shipped bin/pnpm.mjs.

We launch the package manager as node <nodedir>/pnpm .... With pnpm 12 node gets an ELF file (the Linux executable format — a binary, not source), tries to parse it as an ES module and dies:

file:///home/user/.nvm/versions/node/v24.21.0/lib/node_modules/pnpm/pnpm:1
ELF>...
SyntaxError: Invalid or unexpected token

Reported by a user on npx adminforth create-app, but it hits the same way in codeInjector — so npm run dev and custom-component installs break too for anyone on pnpm 12.

Fix

isNodeScriptBin() reads the first two bytes of the resolved bin: #! means a JS entrypoint that still gets launched with the current node binary (pnpm <= 11, npm, corepack shims), anything else is a self-contained executable that is launched directly. Unreadable path keeps the old behaviour.

Applied at the three Unix launch sites:

  • commands/createApp/utils.js — pnpm install / npm install during scaffolding
  • modules/codeInjector.ts — runPackageManagerShell() (custom components install)
  • modules/codeInjector.ts — dev server spawn (pnpm run dev)

Windows branches already invoke pnpm.cmd / npm.cmd through the shell and are untouched.

Verification

Built a node bin dir containing a real node plus the native pnpm 12.5.1 binary, so process.execPath resolution matches a user's nvm layout:

  • old code path: fails with the exact ELF / SyntaxError above
  • new code path: Done in 19ms using pnpm v12.5.1

Detection results on real binaries: pnpm 11.27.1 bin/pnpm.mjs -> true (launched with node), pnpm 12.5.1 native bin -> false (launched directly), npm -> true, missing path -> true.

tsc --noEmit clean (only the pre-existing missing-chokidar error in this checkout).

Please test

Ivan Husev (assigned on AdminForth/1956) — could you retest on your machine with pnpm 12 installed globally:

  1. npx adminforth create-app with pnpm selected
  2. npm run dev in the created app, plus one custom component so the component install path runs

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