Skip to content

Instantly share code, notes, and snippets.

@JLarky
Last active February 6, 2023 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLarky/dd26b3b5dd75335fc5babd58c66b2ad8 to your computer and use it in GitHub Desktop.
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
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