Delete files and directories
Clone or download
Latest commit cdd9c76 Feb 14, 2018
Failed to load latest commit information.
.editorconfig Meta tweaks May 11, 2017
.gitattributes ES2015ify and require Node.js 4 Apr 5, 2017
.gitignore init Jun 21, 2014
.travis.yml Meta tweaks Jun 9, 2017
index.js Add `concurrency` option Jun 9, 2017
license Meta tweaks Jun 9, 2017
package.json 3.0.0 Jun 9, 2017 Update URL to XO Feb 14, 2018
test.js Meta tweaks May 11, 2017

del Build Status XO code style

Delete files and folders using globs

Similar to rimraf, but with a Promise API and support for multiple files and globbing. It also protects you against deleting the current working directory and above.


Support this project and improve your JavaScript skills with this great ES6 course by Wes Bos.
Try his free JavaScript 30 course for a taste of what to expect. You might also like his React and Sublime course.


$ npm install --save del


const del = require('del');

del(['tmp/*.js', '!tmp/unicorn.js']).then(paths => {
	console.log('Deleted files and folders:\n', paths.join('\n'));


The glob pattern ** matches all children and the parent.

So this won't work:

del.sync(['public/assets/**', '!public/assets/goat.png']);

You have to explicitly ignore the parent directories too:

del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);

Suggestions on how to improve this welcome!


del(patterns, [options])

Returns a promise for an array of deleted paths.

del.sync(patterns, [options])

Returns an array of deleted paths.


Type: string Array

See supported minimatch patterns.


Type: Object

See the glob options.


Type: boolean
Default: false

Allow deleting the current working directory and outside.


Type: boolean
Default: false

See what would be deleted.

const del = require('del');

del(['tmp/*.js'], {dryRun: true}).then(paths => {
	console.log('Files and folders that would be deleted:\n', paths.join('\n'));

Type: number
Default: Infinity
Minimum: 1

Concurrency limit.


See del-cli for a CLI for this module and trash-cli for a safe version that is suitable for running by hand.


  • make-dir - Make a directory and its parents if needed
  • globby - User-friendly glob matching


MIT © Sindre Sorhus