API Reference

glob

Match files in the filesystem using shell glob patterns, with async, sync, and streaming APIs.

Official Documentation ↗
CompatibilityThis documentation covers version v14.0.3. Check the official docs for the latest API surface.

Installation

npmnpm install glob

Methods

glob expands shell-style patterns such as **/*.ts into concrete paths and exposes promise, callback, and sync entry points.

Key Features

  • Globstar, brace expansion, and negation support
  • ignore and dot options for precise filtering
  • Streaming API for very large directory trees

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/node-glob@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:49.413Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/isaacs/node-glob@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:49.413Z.

FAQ

Does glob follow symlinks by default?
No. Symlinked directories are not followed unless you set follow: true, which prevents infinite loops caused by circular links.
How do I exclude node_modules?
Pass ignore: "**/node_modules/**". ignore accepts a string or an array evaluated relative to the search root.
Is glob fast enough for large repos?
For tens of thousands of files, yes. To skip walking ignored trees entirely, consider fast-glob or combine ignore with the nocase option.