本文介绍了删除不是空的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Node应用程序中,我需要删除一个包含一些文件的目录,但是只适用于空目录。我怎样才能做到这一点?
In my Node application I need to remove a directory which has some files, but fs.rmdir
only works on empty directories. How can I do this?
推荐答案
这个模块叫做 rimraf
()。它提供了与 rm -Rf
There is a module for this called rimraf
(https://npmjs.org/package/rimraf). It provides the same functionality as rm -Rf
基本用法相同的功能:
Basic usage:
var rimraf = require('rimraf');
rimraf('/some/directory', function () { console.log('done'); });
这篇关于删除不是空的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!