Skip to content

fix(js): support bun-only environments in release-publish executor#34835

Merged
JamesHenry merged 4 commits into
nrwl:masterfrom
AI-JamesHenry-Org:32126
Mar 14, 2026
Merged

fix(js): support bun-only environments in release-publish executor#34835
JamesHenry merged 4 commits into
nrwl:masterfrom
AI-JamesHenry-Org:32126

Conversation

@AI-JamesHenry

Copy link
Copy Markdown
Contributor

Note

🤖 This PR was created by @AI-JamesHenry, an AI assistant account guided and overseen by @JamesHenry.

Current Behavior

nx release publish hardcodes npm view and npm dist-tag add commands, which fails in bun-only environments (e.g., oven/bun Docker images) where npm is not installed, with /bin/sh: 1: npm: not found.

Expected Behavior

nx release publish works in bun-only environments by:

  • Using bun info instead of npm view for checking existing versions/dist-tags
  • Gracefully skipping npm dist-tag add when npm is not available (bun has no equivalent)
  • Showing a clear error message when npm is missing and the package manager is not bun

Changes

  1. npm availability check — Detects npm at executor start via execSync('npm --version'). If npm is missing and PM is not bun, returns a controlled error.
  2. PM-specific view command — Uses bun info / yarn info / pnpm view / npm view based on detected package manager. Only npm/pnpm support field specifiers (versions dist-tags).
  3. Dist-tag guard — Wraps npm dist-tag add section in if (isNpmInstalled) since only npm has this command.
  4. Hardened error handling — Adds fallback parsing for bun's plain-text 404 errors (bun doesn't output JSON errors like npm/pnpm).

This is a clean reimplementation incorporating all review feedback from the original #32252.

Notable: The PackageManagerCommands interface is NOT modified — the view command is built locally in the executor as requested in review feedback.

Related Issue(s)

Fixes #32126

@netlify

netlify Bot commented Mar 14, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs canceled.

Name Link
🔨 Latest commit f7cbfc0
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69b530ce5f079200078403bc

@netlify

netlify Bot commented Mar 14, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev canceled.

Name Link
🔨 Latest commit f7cbfc0
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69b530cea39d9800085d5e67

@nx-cloud

nx-cloud Bot commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 4acfc08

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 50m 7s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 45s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-14 16:06:41 UTC

nx-cloud[bot]

This comment was marked as outdated.

npm version-dependent warnings (e.g., "prefer-frozen-lockfile") cause
snapshot flakiness across CI environments.
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@nx-cloud nx-cloud Bot left a comment

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.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We added a third condition to the bun info error handler in release-publish.impl.ts to recognize bun's plain-text 404 Not Found stderr format as a "package not yet published" signal. Without this, the inner try block would parse an empty stdout as {}, find no E404 code, and incorrectly return success: false before the publish ever ran. This fix allows first-time bun publishes to proceed as expected.

Warning

We could not verify this fix.

diff --git a/packages/js/src/executors/release-publish/release-publish.impl.ts b/packages/js/src/executors/release-publish/release-publish.impl.ts
index 69fb67b0a2..748ab96099 100644
--- a/packages/js/src/executors/release-publish/release-publish.impl.ts
+++ b/packages/js/src/executors/release-publish/release-publish.impl.ts
@@ -282,6 +282,10 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
           !(
             err.stderr?.toString().includes('E404') &&
             err.stderr?.toString().toLowerCase().includes('not found')
+          ) &&
+          !(
+            err.stderr?.toString().includes('404') &&
+            err.stderr?.toString().toLowerCase().includes('not found')
           )
         ) {
           console.error(

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.

Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.

Apply changes locally with:

npx nx-cloud apply-locally P7NN-0cbK

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

Only switch to bun info when pm is bun. Keep npm view for npm/pnpm/yarn
since detectPackageManager() can return pnpm in CI even when the project
uses npm (due to npm_config_user_agent from the parent pnpm process).
@AI-JamesHenry AI-JamesHenry marked this pull request as ready for review March 14, 2026 16:10
@AI-JamesHenry AI-JamesHenry requested a review from a team as a code owner March 14, 2026 16:10
@JamesHenry JamesHenry merged commit f1735bd into nrwl:master Mar 14, 2026
16 of 17 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publishing packages fails if using bun and the npm executable is not available in the environment

2 participants