glob
glob is a library for matching files using glob patterns — the wildcard syntax familiar from shell commands. The library supports standard glob features includi…
Installation
npm install glob
yarn add glob
pnpm add glob
Import
import { glob } from 'glob';Quick Example
import { glob } from 'glob';
const tsFiles = await glob('src/**/*.ts');
const configs = await glob('*.config.{js,ts}');
const allExceptNode = await glob('**/*', {
ignore: 'node_modules/**',
});About glob
glob is a library for matching files using glob patterns — the wildcard syntax familiar from shell commands. The library supports standard glob features including * (match any characters except path separators), ** (match any characters including path separators for recursive directory traversal), ? (match a single character), [...] (character classes), and {a,b} (brace expansion). glob is the underlying pattern matching engine used by countless Node.js tools for file discovery, including test runners finding test files, build tools locating source files, and linters discovering files to check. The library provides both callback and promise-based APIs, with options for ignoring patterns, following symlinks, case-insensitive matching, dot file inclusion, and result sorting. glob v10+ is a complete rewrite with significantly improved performance, featuring a walk-based approach that reduces filesystem calls. The library handles platform-specific path separators and provides both absolute and relative path output. While fast-glob and globby have gained popularity as faster alternatives with more features, glob remains the most widely used file matching library in the Node.js ecosystem.
Quick Facts
| Package | glob |
| Category | Utility |
| Weekly Downloads | 25M+ |
| License | ISC |
| Install | npm install glob |
Related Packages
fast-glob is a high-performance glob matching library for Node.js that provides significant speed im…
Globby is a user-friendly glob matching library built on top of fast-glob that provides a convenient…
minimatch is a minimal matching utility that tests whether a filename or path string matches a given…
rimraf is a Node.js implementation of the Unix rm -rf command, providing cross-platform recursive di…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.