7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.js v10のfsでasync/await

Last updated at Posted at 2018-09-01

Node.jsのv10で、fsのpromise版が登場して、async/awaitでかける様になりました。最近書き方が変わって今はこれ。

const fs = require("fs").promises;

const displayFiles = async dir => {
  const files = await fs.readdir(dir);
  console.log(files);
};

displayFiles("./");

まだexperimentalなので以下の警告が出ます。

ExperimentalWarning: The fs.promises API is experimental
7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?