yoshiweb.NET

ディレクトリがなければ作成する (node.js)



const fs = require('fs');

const path = 'ファイルパス';

if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true });
}


参考
Node.js v10.12.0からは再帰的にディレクトリを作成できる。
ディレクトリがなければ作成するNode.jsのコード


投稿日 : 2021年12月20日 - yoshiweb - カテゴリ: 雑記

コメント

投稿者 : y2mate.ws

Hi there! I could have sworn I've visited this blog before but after
looking at many of the articles I realized it's new to me.

Anyhow, I'm definitely happy I discovered it and I'll be book-marking it and checking back often!
2025年09月18日 06時57分13秒