<aside> đźš§
Note: This document collects my development notes and has been organized and translated into English with the help of AI. Some phrasing may be awkward, and there may be mistakes. Please feel free to point out any errors.
</aside>
When creating a new project via npx create-electron-app (or npx create-electron-app@latest), the package manager detection always defaults to npm.
This happens because:
npm/npx.As a result, initialization (template copy, package.json merge, config setup) always proceeds with npm assumptions. Later switching to pnpm install (or Yarn Berry) leaves the project missing important package-manager–specific defaults (e.g., .npmrc, pnpm.onlyBuiltDependencies, hoist settings).
With pnpm v10, lifecycle script execution changes mean that postinstall no longer compensates for this mismatch. The end state becomes a “mixed npm + pnpm project,” leading to errors and user confusion.
resolvePackageManager() logic (user-agent → lockfile → NODE_INSTALLER → fallback) can’t detect pnpm/yarn.resolvePackageManager() again and return a different result.postinstall, but this no longer holds reliably.Conclusion: without a single explicit PM decision at init, template logic can’t execute safely or consistently.
-package-manager) → explicit, fast.FORGE_PACKAGE_MANAGER) → simple, but global dependency.package.json.packageManager field in template → standards-based, template-only.