Last active
February 6, 2023 18:26
-
-
Save JLarky/dd26b3b5dd75335fc5babd58c66b2ad8 to your computer and use it in GitHub Desktop.
how to list files in a folder in node.js https://sharegpt.com/c/RW0fYB3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function listFiles(dir: string) { | |
try { | |
const { readdir } = await import('fs/promises'); | |
const files = await readdir(dir); | |
console.log(files); | |
} catch (err) { | |
throw err; | |
} | |
} | |
console.log(await listFiles('.')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment