Micromatch is a comprehensive and highly performant JavaScript utility for glob matching, serving as a faster and more feature-rich alternative to older libraries like minimatch and multimatch. The current stable version is 4.0.8, actively maintained with regular updates to address bug fixes and security vulnerabilities. Key differentiators include its speed and extensive support for the Bash 4.3 specification, often surpassing Bash itself in terms of adherence to its glob test suite. It is widely adopted across the JavaScript ecosystem for file system operations, build tooling, and configuration management, providing a robust solution for pattern matching in both Node.js and browser environments.
npm install micromatchVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic glob matching, filtering lists of strings, using negation patterns, and performing boolean checks with micromatch. It covers common scenarios like selecting files by extension or excluding specific types, showcasing the flexibility of its API.
Review the official changelog for v4.0.0 and update your glob patterns and options usage accordingly. Ensure your Node.js version meets the minimum requirement.
Use forward slashes (`/`) for path separators in glob patterns instead of backslashes (`\`) to ensure consistent behavior across operating systems and to avoid unintended escape sequences. Escape literal backslashes with another backslash if needed.
Upgrade to micromatch `4.0.8` or newer immediately. Implement input validation for user-supplied glob patterns to reject overly complex or malformed inputs. Consider adding timeout mechanisms for pattern matching operations as a defensive measure.
If patterns that previously worked now fail or yield different results, double-check that your glob expressions are syntactically valid according to the Bash 4.3 specification and micromatch's documentation. Adjust patterns to be strictly correct.
Try installing with `--legacy-peer-deps` (`npm install micromatch --legacy-peer-deps`) or `--force` (`npm install micromatch --force`) as a temporary workaround, then investigate the underlying dependency tree to resolve conflicts properly.
Ensure `micromatch` is listed in your `package.json` and run `npm install` or `yarn install`. Verify the package exists in your `node_modules` directory and that your import path is correct (e.g., `import micromatch from 'micromatch';`).
Use `import micromatch from 'micromatch';` and then call methods as `micromatch.isMatch(...)` or `micromatch.not(...)`. Do not attempt `import { isMatch } from 'micromatch';` as these are not named exports.Always use forward slashes (`/`) as path separators in your glob patterns, even on Windows. If you need to match a literal backslash, you must escape it (e.g., `\\`).