Skip to content

[build-tools][worker] keep NPM_TOKEN working on newer pnpm and explain pnpm Node.js mismatches - #4729

Merged
hSATAC merged 1 commit into
mainfrom
ash/eng-28287-newer-pnpm-breaks-two-eas-build-defaults-npm_token-in-the
Oct 28, 2026
Merged

hSATAC merged 1 commit into
mainfrom
ash/eng-28287-newer-pnpm-breaks-two-eas-build-defaults-npm_token-in-the

Conversation

@hSATAC

@hSATAC hSATAC commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

pnpm 10.34.2+ and 11.5.3+ ignore ${NPM_TOKEN} in a project-level .npmrc, so the file EAS Build generates for NPM_TOKEN no longer authenticates private installs on the default images. Projects that pin pnpm 11 on a Node 20 image also crash on node:sqlite without the build error saying why.

How

  • Append //registry.npmjs.org/:_authToken=${NPM_TOKEN} to the builder's npm user config on EAS Build, where every package manager still expands it, and leave the project .npmrc to the user. The file is whatever npm config get userconfig reports for the build env (~/.npmrc unless NPM_CONFIG_USERCONFIG points elsewhere), so npm applies its own path rules.
  • Keep generating the project .npmrc on local builds.
  • Share one setUpNpmrcAsync between the legacy prepare-project path and the eas/use_npm_token step.
  • Add a user error for pnpm's "requires at least Node.js" banner that names the eas.json node value to set.
  • Raise the same error when the worker reinstalls pnpm under a node pinned in eas.json, instead of the generic "Failed to install pnpm" message.

Stacked on #4728, which removes the only env-less Yarn 1 spawn that would abort on the placeholder.

Test Plan

Added unit coverage for the ~/.npmrc append on EAS Build, the NPM_CONFIG_USERCONFIG override, the project .npmrc on local builds, the new error handler, and the worker's pnpm reinstall failure. Also verified against a local registry that pnpm 10.34.7 / 11.9.0 / 11.28.6 / 12.15.0, npm, Yarn 1 and bun expand the user-level placeholder and that a project-level entry wins, and ran lint, TypeScript checks and the changeset validation.

@hSATAC
hSATAC added this pull request to stack #4730 October 23, 2026 12:17
@linear-code

linear-code Bot commented Oct 23, 2026

Copy link
Copy Markdown

ENG-28287

@hSATAC
hSATAC marked this pull request as ready for review October 23, 2026 12:21
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.79%. Comparing base (15e2302) to head (92cd573).

Files with missing lines Patch % Lines
...src/buildErrors/pnpmUnsupportedNodeVersionError.ts 76.93% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4729      +/-   ##
==========================================
+ Coverage   75.75%   75.79%   +0.05%     
==========================================
  Files        1061     1063       +2     
  Lines       52824    52855      +31     
  Branches    11564    11567       +3     
==========================================
+ Hits        40011    40058      +47     
+ Misses      11833    11818      -15     
+ Partials      980      979       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

{
// example log: "warn: This version of pnpm requires at least Node.js v22.13" followed by "warn: The current version of Node.js is v20.19.4"
regexp:
/This version of pnpm requires at least Node\.js v([\d.]+)\n.*The current version of Node\.js is v([\d.]+)/,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be useful to show this message in installPnpm() too, for users who set their pnpm version in eas.json

Comment thread packages/build-tools/src/utils/npmrc.ts Outdated
const projectNpmrcPath = path.join(ctx.buildDirectory, '.npmrc');
async function addNpmTokenToHomeNpmrcAsync(logger: bunyan): Promise<void> {
logger.info(`Adding "${NpmrcAuthTokenLine}" to ~/.npmrc`);
await fs.appendFile(path.join(os.homedir(), '.npmrc'), `\n${NpmrcAuthTokenLine}\n`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If NPM_CONFIG_USERCONFIG is set, I believe the token needs to go in that file instead of ~/.npmrc

@hSATAC hSATAC changed the title [build-tools] keep NPM_TOKEN working on newer pnpm and explain pnpm Node.js mismatches [build-tools][worker] keep NPM_TOKEN working on newer pnpm and explain pnpm Node.js mismatches Oct 28, 2026
@hSATAC
hSATAC force-pushed the ash/eng-28287-newer-pnpm-breaks-two-eas-build-defaults-npm_token-in-the branch from 727d989 to 5ee1232 Compare October 28, 2026 08:59
Base automatically changed from ash/eng-28285-easrepack-installs-exporepack-app-with-a-hard-coded-yarn-add to main October 28, 2026 09:10
…n pnpm Node.js mismatches

pnpm 10.34.2+ and 11.5.3+ ignore ${NPM_TOKEN} placeholders in a project-level .npmrc (GHSA-3qhv-2rgh-x77r) but still expand them in the npm user config. On EAS Build the NPM_TOKEN credential now goes into the file `npm config get userconfig` reports for the build env (~/.npmrc unless NPM_CONFIG_USERCONFIG points elsewhere) whenever the job has NPM_TOKEN, and the project .npmrc is left to the user. Local builds keep creating the project .npmrc, because the home directory there belongs to the developer. The legacy PREPARE_PROJECT path and the eas/use_npm_token step share one helper.

Projects that pin pnpm 11 through packageManager on a Node 20 image crash on node:sqlite right after pnpm's "requires at least Node.js v22.13" banner. A new user error names the eas.json node value to set or the pnpm version to change. The worker raises the same error when it reinstalls pnpm under a node version pinned in eas.json, instead of the generic "Failed to install pnpm" message: the typed error it threw before never reached the log handlers, and the probe's piped output never reached the log.
@hSATAC
hSATAC force-pushed the ash/eng-28287-newer-pnpm-breaks-two-eas-build-defaults-npm_token-in-the branch from 5ee1232 to 92cd573 Compare October 28, 2026 09:10
@github-actions

Copy link
Copy Markdown

✅ Thank you for adding a changeset!

@hSATAC
hSATAC merged commit 695f567 into main Oct 28, 2026
10 checks passed
@hSATAC
hSATAC deleted the ash/eng-28287-newer-pnpm-breaks-two-eas-build-defaults-npm_token-in-the branch October 28, 2026 09:19
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.

2 participants