Skip to content

Support .mjs entry scripts in pnpm launchers - #2115

Draft
wlbrough wants to merge 1 commit into
volta-cli:mainfrom
wlbrough:fix/pnpm-mjs-launcher
Draft

wlbrough wants to merge 1 commit into
volta-cli:mainfrom
wlbrough:fix/pnpm-mjs-launcher

Conversation

@wlbrough

Copy link
Copy Markdown

Fixes #2114

Summary

pnpm 12 ships bin/pnpm.mjs and bin/pnpx.mjs instead of the .cjs entry scripts used by earlier versions (e.g. 10.x). Volta generates its own bin/pnpm / bin/pnpx launchers after unpacking the archive, and those hardcoded .cjs, so running pnpm 12 failed with Cannot find module '.../bin/pnpm.cjs'.

The launchers now use <tool>.mjs when it exists in the unpacked bin directory and fall back to <tool>.cjs otherwise. This applies to both the shell launcher and the Windows .cmd launcher.

Testing

  • Added unit tests for write_launcher covering both the .mjs and .cjs layouts.
  • cargo test -p volta-core passes (108 tests); cargo fmt --check and cargo clippy --all-targets are clean.
  • Manually confirmed against the pnpm 12.15.0 tarball, which contains only bin/pnpm.mjs and bin/pnpx.mjs.

Note: pnpm versions that are already installed keep their existing launchers. Reinstalling them (after removing ~/.volta/tools/image/pnpm/<version>) regenerates the launchers.

🤖 Generated with Claude Code

pnpm 12 ships bin/pnpm.mjs and bin/pnpx.mjs instead of .cjs files, so
the generated launchers pointed at missing files. Use the .mjs script
when present and fall back to .cjs otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Error: Cannot find module ... 'pnpm.cjs' when using pnpm 12 in Volta v1.1.1 on macOS

1 participant