Generation

generate functionWed, 15 Feb 2023

移除node_modules目录

const fs = require('fs') const path = require('path') function travel(dir, callback, finish) { fs.readdirSync(dir).forEach(function(file) { var pathname = path.join(dir, file) if (fs.statSync(pathname).isDirectory()) { travel(pathname, callback, finish) } else { callback(pathname) } }) finish() } travel('../learn-node/node_modules', function(pathname) { console.log(pathname) fs.unlinkSync(pathname) }, function() { console.log('finished') })

Javascript
Generate More

Want to kickstart your project?Use the new AI Studio to create your code