npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

remove-glob

v0.4.10

Published

A tiny utility to remove items or directories recursively, also supports glob

Readme

License: MIT TypeScript Vitest codecov npm npm npm bundle size

remove-glob

A tiny cross-platform utility to remove items or directories recursively, it also accepts an optional glob pattern. There's also a CLI for easy, cross-platform usage. It uses 2 small dependencies tinyglobby for glob support and cli-nano for the CLI.

Inspired by rimraf and premove but also supports glob pattern to remove multiple files or directories.

Install

npm install remove-glob

Command Line

A remove binary is available, it takes an optional path argument (zero or multiple file/directory paths) to be removed or a --glob pattern instead of path(s).

[!NOTE] The paths and glob arguments are both optionals, but you must provide at least 1 of them. However, please note that providing both of them simultaneously is not supported and will throw an error (choose the option that is best suited to your use case).

Usage:
  remove [paths..] [options]  Remove all items recursively

Arguments:
  paths           directory or file paths to remove                                         [string..]

Options:
      --cwd       Directory to resolve from (default ".")                                   [string]
  -d, --dryRun    Show which files/dirs would be deleted but without actually removing them [boolean]
  -g, --glob      Glob pattern(s) to find which files/dirs to remove                        [array]
  -s, --stat      Show the stats of the items being removed                                 [boolean]
  -V, --verbose   If true, it will log each file or directory being removed                 [boolean]
  -h, --help      Show help                                                                 [boolean]
  -v, --version   Show version number                                                       [boolean]

Remove files or directories. Note: on Windows globs must be double quoted, everybody else can quote however they please.

# remove "foo" and "bar" via `npx`
$ npx remove foo bar

# or remove using glob pattern(s)
$ npx remove --glob \"dist/**/*.js\"
$ npx remove --glob=\"dist/**/*.js\" --glob=\"packages/*/tsconfig.tsbuildinfo\"

# install globally, use whenever
$ npm install remove-glob -g
$ remove foo bar
$ remove --glob \"dist/**/*.{js,map}\"

[!NOTE] When using the --glob option, it will skip .git/ and node_modules/ directories by default.

Usage

import { resolve } from 'node:path';
import { removeSync } from 'remove-glob';

// remove via paths
removeSync({ paths: './foobar' });
removeSync({ paths: ['./foo/file1.txt', './foo/file2.txt'] });

// or remove via glob pattern
removeSync({ glob: 'foo/**/*.txt' });

// Using `cwd` option
const dir = resolve('./foo/bar');
await removeSync({ paths: ['hello.txt'], cwd: dir });

JavaScript API

import { removeSync } from 'remove-glob';

removeSync(opt, callback);

The first argument is an object holding any of the options shown below. The last argument is an optional callback function that will be executed after all files were removed.

{
  cwd: string;              // directory to resolve your `filepath` from, defaults to `process.cwd()`
  dryRun: boolean;          // show what would be copied, without actually copying anything
  paths: string | string[]; // filepath(s) to remove – may be a file or a directory.
  glob: string;             // glob pattern to find which files/directories to remove
  stats: boolean;           // show some statistics after execution (time + file count)
  verbose: boolean;         // print more information to console when executing the removal
}

[!NOTE] The first argument is required and it must include either a paths or a glob, but it cannot include both options simultaneously.

Used by

I use it in most of my own open source projects as a Dev Dependency (feel free to modify this list and add your project(s) as well)