Skip to content

Resolve i18next-cli bin via module resolution for pnpm compatibility - #2

Merged
oscarfonts merged 2 commits into
mainfrom
COMMONS-124-pnpm-compat
May 26, 2026
Merged

Resolve i18next-cli bin via module resolution for pnpm compatibility#2
oscarfonts merged 2 commits into
mainfrom
COMMONS-124-pnpm-compat

Conversation

@oscarfonts

@oscarfonts oscarfonts commented May 26, 2026

Copy link
Copy Markdown
Member

Problem

When using @geomatico/i18n-linter in pnpm-managed projects, the linter would fail silently because it internally calls spawnSync('i18next-cli', ...), which looks up the binary via PATH (i.e. the consumer project's node_modules/.bin).

pnpm's strict dependency isolation prevents transitive packages from being hoisted to the root node_modules/.bin. Since i18next-cli is a dependency of i18n-linter and not of the consumer project, pnpm does not expose it there.

The symptom was the bundle sync check exiting with code 1 without showing any key diff, because the i18next-cli process never actually started.

Solution

Instead of relying on PATH, the absolute path to the i18next-cli binary is resolved using createRequire(import.meta.url), which resolves relative to i18n-linter's own location (its own node_modules). It is then launched via process.execPath (the same running Node.js process).

This works correctly with both npm and pnpm, and consumer projects no longer need to declare i18next-cli as a direct dependency.

oscarfonts and others added 2 commits May 26, 2026 11:57
Replaces spawnSync('i18next-cli', ...) with a node call to the binary
resolved via createRequire(import.meta.url). This ensures i18next-cli
is found relative to i18n-linter's own node_modules rather than relying
on it being hoisted to the consumer's root node_modules/.bin, which
breaks under pnpm's strict dependency isolation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@oscarfonts
oscarfonts merged commit a6934a4 into main May 26, 2026
1 check passed
@oscarfonts
oscarfonts deleted the COMMONS-124-pnpm-compat branch May 26, 2026 10:02
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