Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
prettier-plugin-bq
✓ import {} from 'prettier-plugin-bq' // no export, plugin auto-detected
✗ const plugin = require('prettier-plugin-bq')
Plugin is not a JavaScript module to import; it's discovered via prettier's plugin resolution. Use .prettierrc or CLI --plugin flag.
prettier
✓ import prettier from 'prettier'
✗ const prettier = require('prettier')
Prettier 3 is ESM-only; use import syntax or dynamic import.
default (prettier instance)
✓ import * as prettier from 'prettier'
✗ const prettier = require('prettier')
For programming usage, use ES module import. CommonJS require will fail in prettier 3.
Install prettier and the plugin, create a SQL file, format it using the CLI with --plugin flag.
npm install --save-dev prettier prettier-plugin-bq
echo "SELECT
name,
SUM(salary) AS total_salary
FROM
employees
WHERE
department = 'Engineering'
GROUP BY
name
HAVING
total_salary > 100000
ORDER BY
total_salary DESC;" > query.sql
npx prettier --write query.sql --plugin=prettier-plugin-bq
prettier --version
Debug
Known issues
gotchaPlugin does not work with prettier v2; requires prettier ^3.2.4. If you have prettier v2 installed, the plugin will not be loaded and no formatting will occur.fixUpdate prettier to v3.2.4 or later: npm install prettier@latest --save-dev
affects: <1.0.0 or prettier <3.2.4
deprecatedOption printPseudoColumnsInUpperCase was merged into printKeywordsInUpperCase. Using the old name may be ignored or cause errors in future versions.fixUse printKeywordsInUpperCase instead of printPseudoColumnsInUpperCase.
affects: >=1.0.0
gotchaJinja template support is experimental and may produce incorrect formatting or errors if Jinja statements do not contain valid SQL expressions.fixEnsure Jinja tags wrap valid SQL expressions; avoid placing statements like WHERE or JOIN entirely inside Jinja conditionals.
affects: >=1.0.0
gotchaThe plugin does not follow any famous style guides; it formats according to its own heuristics, which may differ from expectations of BigQuery style guides.fixReview formatting output and adjust options (e.g., printKeywordsInUpperCase) to match preferred style.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-bq'
The plugin is not installed or not resolved by prettier. Usually because prettier v2 is installed, or the plugin is not listed in .prettierrc.
fixnpm install prettier@latest prettier-plugin-bq --save-dev and add "plugins": ["prettier-plugin-bq"] to .prettierrc
TypeError: Cannot read properties of undefined (reading 'format')
Using require('prettier-plugin-bq') and trying to call it as a function. The plugin is not a module to import programmatically.
fixDo not import the plugin directly; configure it via .prettierrc or CLI.
Audit
Dependencies
prettierrequiredpeer dependency required for plugin to work