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.
default
✓ import plugin from 'prettier-plugin-glsl'
✗ const plugin = require('prettier-plugin-glsl')
The plugin is a default export. Prettier auto-discovers plugins, so explicit import is usually unnecessary.
glsl-parser
✓ import { parsers } from 'prettier-plugin-glsl'; const glslParser = parsers['glsl-parser'];
✗ import { glsl-parser } from 'prettier-plugin-glsl'
The parser name is a string key, not a named export. Access via parsers object.
printers
✓ import { printers } from 'prettier-plugin-glsl'
✗ import printers from 'prettier-plugin-glsl/printers'
Printers are exported as a named export from the package root.
Installation, configuration, and basic formatting of a GLSL vertex shader file.
// Install prettier and plugin
// npm install --save-dev prettier prettier-plugin-glsl
// .prettierrc
{
"plugins": ["prettier-plugin-glsl"],
"overrides": [
{
"files": ["*.frag", "*.vert", "*.glsl"],
"options": {
"parser": "glsl-parser"
}
}
]
}
// Format all GLSL files in project
// npx prettier --write "**/*.{glsl,frag,vert}"
// Example input.vs
#version 330 core
layout(location = 0) in vec3 aPos;
void main()
{
gl_Position = vec4(aPos, 1.0);
}
// After formatting: npx prettier --write input.vs
// Output:
#version 330 core
layout(location = 0) in vec3 aPos;
void main() {
gl_Position = vec4(aPos, 1.0);
}
prettier --version
Debug
Known issues
breakingThis plugin requires Prettier version ^3.0.0. It will not work with Prettier 2.x.fixUpgrade Prettier to version 3 or later: npm install prettier@latest
affects: <3.0.0 (of prettier)
deprecatedThe plugin is in active development; breaking formatting changes may occur in any minor or patch version.fixPin to a specific version if stability is required: "prettier-plugin-glsl": "0.2.5"
affects: >=0.0.0
gotchaFiles with .frag extension are recognized as JavaScript by default. Override the parser in Prettier config to format them as GLSL.fixAdd overrides in Prettier config: { "overrides": [{ "files": ["*.frag"], "options": { "parser": "glsl-parser" } }] } affects: >=0.0.0
gotchaComplex #if/#else/#endif mixed with if/else can produce invalid output. The plugin treats preprocessor directives as statements, not as block modifiers.fixRestructure code to avoid mixing preprocessor conditionals with C-style if/else blocks, or manually verify formatting.
affects: >=0.0.0
gotchaPlugin auto-recognizes only certain file extensions (e.g., .glsl, .vert, .frag). Custom extensions may require explicit parser option.fixSpecify parser in Prettier config: { "overrides": [{ "files": ["*.custom"], "options": { "parser": "glsl-parser" } }] } affects: >=0.0.0
Errors
Common errors & fixes
Error: Couldn't resolve plugin "prettier-plugin-glsl"
Plugin not installed or not in node_modules.
fixRun 'npm install --save-dev prettier-plugin-glsl' and ensure it appears in package.json devDependencies.
Cannot find module 'prettier-plugin-glsl'
Plugin is not installed or path resolution issue with Prettier 3.x plugin resolution.
fixVerify installation: npm list prettier-plugin-glsl. If using Yarn PnP, add plugin to pluggable dependencies.
[error] Invalid configuration file: "parser" option is not a valid parser name
Typo in parser name, e.g., 'glsl' instead of 'glsl-parser'.
fixUse correct parser name: "glsl-parser" as exported by the plugin.
TypeError: prettier.getSupportInfo is not a function
Using an older version of Prettier (<3.0.0) that doesn't support plugin API used by this plugin.
fixUpgrade Prettier to version 3 or later: npm install prettier@latest
Audit
Dependencies
prettierrequiredpeer dependency - required for the plugin to function