nodejs 获取指定路径下所有的文件夹名
示例:获取 ./components 下所有的文件夹名称
let components = [] const files = fs.readdirSync('./components') files.forEach(function (item, index) { let stat = fs.lstatSync("./components/" + item) if (stat.isDirectory() === true) { components.push(item) } }) console.log(components);