Replacements for glob
tinyglobby
tinyglobby provides a similar API.
Example:
ts
import { glob } from 'glob'
import { glob } from 'tinyglobby'
const files = await glob('**/*.ts')Most options available to glob are available in tinyglobby, read more at the tinyglobby documentation.
fs.glob (native, since Node 22.x)
fs.glob is built into modern versions of Node.
Example:
ts
import { glob } from 'glob'
import { glob } from 'node:fs/promises'
const files = await glob('src/**/*.ts', {
const files = await Array.fromAsync(glob('src/**/*.ts', {
cwd,
})
})) You can also iterate over the results asynchronously:
ts
for await (const result of glob('src/**/*.ts', { cwd })) {
// result is an individual path
console.log(result)
}fdir
fdir offers similar functionality but through a different API (and tinyglobby is actually built on top of it).
Example:
ts
import { fdir } from 'fdir'
import { glob } from 'glob'
const files = new fdir()
.withBasePath()
.glob('src/**/*.ts')
.crawl(cwd)
.withPromise()
const files = await glob('src/**/*.ts', {
cwd,
maxDepth: 6
})