Registry / devops / prettier-plugin-nginx

prettier-plugin-nginx

JSON →
library1.0.3jsnpmunverified

prettier-plugin-nginx is a Prettier plugin that formats NGINX configuration files (.nginx, .nginxconf). Version 1.0.3 ships TypeScript types and targets modern Prettier (v2+). It is written in TypeScript and depends only on Prettier. Differentiators: opinionated formatting with configurable alignment, parameter wrapping, and continuation indentation; supports standard NGINX directives but not extensions like lua-nginx-module. Release cadence is low; last release was 2024.

npm install prettier-plugin-nginx
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-NG
P
prettier-plugin-nginx
devopsjavascriptv1.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import prettier from 'prettier-plugin-nginx'
✗ const prettier = require('prettier-plugin-nginx')
Plugin is used via Prettier API, not direct default import. Use Prettier's resolver.
Pugins
✓ import * as prettier from 'prettier'; const options = { plugins: ['prettier-plugin-nginx'] }
✗ const options = { plugins: [require('prettier-plugin-nginx')] }
Pass the plugin name string to Prettier options; Prettier resolves it.
alignUniversally
✓ import { alignUniversally } from 'prettier-plugin-nginx'
✗ const alignUniversally = require('prettier-plugin-nginx').alignUniversally
Named exports for options available since v1. Prettier imports these via plugin options.

Formats an NGINX config string using Prettier with the plugin, enabling directive alignment and parameter wrapping.

import prettier from 'prettier'; import nginxPlugin from 'prettier-plugin-nginx'; const code = `server { listen 80; server_name example.com; location / { proxy_pass http://proxy; } }`; prettier.format(code, { parser: 'nginx', plugins: [nginxPlugin], alignDirectives: true, wrapParameters: true }).then(result => console.log(result));
Debug
Known issues
gotchaPlugin does not support lua-nginx-module or other multi-language extensions; embedded code will break.
fix
Avoid using with configs containing Lua blocks, or handle those manually.
affects: all
gotchaPlugin only formats .nginx and .nginxconf files by default; other extensions require explicit parser override.
fix
Set parser to 'nginx' in Prettier options or rename files.
affects: all
breakingv1.0.0 introduced named exports for configuration options; previous versions used plugin-local options only.
fix
Upgrade to v1.0.0+ and use named exports like `alignUniversally` if needed.
affects: <1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-nginx'
Plugin not installed or not in node_modules.
fix
Run `npm install --save-dev prettier-plugin-nginx`
[error] Invalid parser option: 'nginx'
Prettier version <2.0 or plugin not loaded properly.
fix
Ensure Prettier >=2.0 and pass plugin via `plugins` array.
TypeError: prettier.format is not a function
Using wrong import (default vs named) for Prettier.
fix
Use `import prettier from 'prettier'` (ESM) or `const prettier = require('prettier')` (CJS).
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
prettierrequiredpeer dependency – used as the formatting engine
Agent activity
2 hits · last 30 days
node
2
Resources
prettier-plugin-nginx — npm install prettier-plugin-nginx · libregistry