Registry / devops / nginx-linter

nginx-linter

JSON →
library0.7.0jsnpmunverified

A CLI tool for linting and formatting Nginx configuration files, version 0.7.0. It validates style and common pitfalls with built-in rules such as 'if-is-evil', indentation enforcement, line-ending consistency, location ordering, and trailing whitespace checks. Requires Node 18+. Designed for DevOps workflows, it offers opinionated defaults but is configurable. Compared to alternatives like gixy, it focuses on style and best practices rather than security analysis.

npm install nginx-linter
INSTALL
IMPORT
SIG · NGINX-LINTER
N
nginx-linter
devopsjavascriptv0.7.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Linter
import { Linter } from 'nginx-linter'
const Linter = require('nginx-linter').Linter
Package is ESM-only since v0.7.0. Named export.
default
import nginxLinter from 'nginx-linter'
const nginxLinter = require('nginx-linter')
Default export is available in ESM, but not CommonJS.
cli
import { cli } from 'nginx-linter'
CLI function for programmatic use when not using the command line.
LinterOptions
import type { LinterOptions } from 'nginx-linter'
import { LinterOptions } from 'nginx-linter'
Type-only import for TypeScript users.

Installation and basic usage of nginx-linter to lint an Nginx configuration file.

# Install globally npm install -g nginx-linter # Lint default Nginx config nginx-linter /path/to/nginx.conf # With options: indentation 2 spaces, line-ending lf nginx-linter --indentation 2 --line-ending lf /etc/nginx/nginx.conf
Debug
Known issues
breakingv0.7.0 drops Node 16 support; requires Node 18+
fix
Upgrade to Node 18 or later.
affects: >=0.7.0
gotchaDefault config path is /etc/nginx/ which may not exist on non-Linux systems
fix
Always specify a path or use custom config via --config-file.
affects: <0.7.0
gotchaIf-is-evil rule may reject perfectly safe 'if' usage in rewrites or named locations
fix
Set if-is-evil rule to 'none' or adjust mode in .nginx-linterrc.
affects: >=0.1.0
deprecatedTrailing whitespace rule deprecated in favor of general style rules starting v0.6.0
fix
Use 'trailing-whitespace: warning' or remove from config.
affects: >=0.6.0
Errors
Common errors & fixes
Error: Cannot find module 'nginx-linter'
Package not installed or not in NODE_PATH
fix
Run 'npm install -g nginx-linter' or add to project dependencies.
SyntaxError: Unexpected token 'export'
ESM export used in CommonJS context without type: module
fix
Add 'type': 'module' to package.json or use dynamic import.
nginx-linter: error: unknown option '--indent'
Wrong option name, correct is --indentation
fix
Use '--indentation' instead of '--indent'.
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
nginx-linter — npm install nginx-linter · libregistry