Skip to content

fix: prevent browserslist config resolution error with pnpm#2043

Open
pannous wants to merge 1 commit intoasyncapi:masterfrom
pannous:fix/pnpm-browserslist-1781
Open

fix: prevent browserslist config resolution error with pnpm#2043
pannous wants to merge 1 commit intoasyncapi:masterfrom
pannous:fix/pnpm-browserslist-1781

Conversation

@pannous
Copy link

@pannous pannous commented Mar 16, 2026

Summary

  • Fixes [BUG] Generator error when using pnpm to create documentation #1781 — Generator fails with Unknown browser query 'basedir=$(dirname ...' when CLI is installed globally via pnpm
  • Sets BROWSERSLIST=defaults env var before generation to prevent browserslist from walking directories and mistakenly parsing pnpm's shell wrapper script as a config file
  • Restores the env var in a finally block to avoid side effects

Root Cause

When installed via pnpm, the global bin/ directory contains a shell wrapper script named browserslist. The browserslist package walks up directories looking for config files, finds this shell script, and tries to parse it as a browserslist query — causing the error.

Test plan

  • Install asyncapi CLI globally via pnpm (pnpm add -g @asyncapi/cli)
  • Run asyncapi generate fromTemplate <spec.yaml> @asyncapi/html-template -o docs
  • Verify documentation generates without browserslist error
  • Verify existing tests pass (npm test)

When asyncapi CLI is installed globally via pnpm, the global bin
directory contains a shell wrapper script named "browserslist".
The browserslist package walks up directories looking for config
files and mistakenly parses this shell script as a config, causing:

  "Unknown browser query 'basedir=$(dirname "$(echo "$0" | sed -e 's'"

Fix: set BROWSERSLIST=defaults env var before generation to prevent
the directory walk. The env var is restored afterward in a finally
block to avoid side effects.

Fixes asyncapi#1781
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Generator error when using pnpm to create documentation

1 participant