minimatch
A minimal matching utility that compiles glob patterns into anchored JavaScript RegExp objects.
Official Documentation ↗v9. Check the official docs for the latest API surface.Installation
npm install minimatchMethods
No methods match this filter.
minimatch translates glob syntax into regular expressions and is used by npm, glob, and many build tools.
Key Features
- Single-call matching or compiled reusable Matcher
- Globstar, negation, and brace expansion
- Extglob and regexp features can be toggled off
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:56.598Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- For example, patterns like aaaaaaaaaaa when matched against a string like ‘a’.repeat(50) + ‘b’ would have to repeatedly backtrack through every failure. (https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md)
- If this would make more than braceExpandMax patterns, or add more than 1,000,000 path portions in total, construction throws a RangeError. (https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md)
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:56.598Z.
- Libraries that assemble Regular Expressions from arbitrary input are thus vulnerable to patterns that cause pathological behavior. (https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md)
- Though this library is not vulnerable to ReDOS, any library that performs pattern matching based on arbitrary input will potentially have edge cases where it performs suboptimally. (https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md)
- Back-slashes in patterns will always be interpreted as escape characters, not path separators. (https://cdn.jsdelivr.net/gh/isaacs/minimatch@latest/README.md)
FAQ
- How is minimatch different from a plain RegExp?
- minimatch translates *, **, ?, [], and {a,b} into an anchored RegExp and applies path segment semantics, which raw RegExp does not.
- Does ** cross directory boundaries?
- Yes. globstar matches zero or more path segments, so a/**/b matches a/b, a/x/b, and a/x/y/b.
- Can I disable brace expansion?
- Set noext: true to disable {a,b} expansion and noglobstar: true to treat ** as a single path segment.
Report a problem with this API docOpens a pre-filled issue on GitHub.