{"id":878,"date":"2026-05-20T09:51:25","date_gmt":"2026-05-20T01:51:25","guid":{"rendered":"https:\/\/junai.ai\/blog\/nodejs-fs-async-sync-6\/"},"modified":"2026-05-20T09:51:25","modified_gmt":"2026-05-20T01:51:25","slug":"nodejs-fs-async-sync-6","status":"publish","type":"post","link":"https:\/\/junai.ai\/blog\/nodejs-fs-async-sync-6\/","title":{"rendered":"fs \ubaa8\ub4c8 \u2014 \ud30c\uc77c \uc77d\uae30\u00b7\uc4f0\uae30, \ub3d9\uae30 vs \ube44\ub3d9\uae30"},"content":{"rendered":"\n<!-- WordPress REST API \ubc1c\ud589\uc6a9 HTML (\uc790\ub3d9 \uc0dd\uc131) -->\n<!-- WP-FEATURED-MEDIA-ID: 824 -->\n<div style=\"max-width:800px;margin:0 auto;\">\n<style>\n:root {--color-primary:#059669;--color-accent:#10b981;--color-bg:#fafbfc;--color-bg-card:#fff;--color-text:#1a202c;--color-text-muted:#64748b;--hero-start:#064e3b;--hero-end:#059669;}\n*{box-sizing:border-box;}\n.container{max-width:760px;margin:0 auto;padding:0 24px 80px;}\n.hero{background:linear-gradient(135deg,var(--hero-start) 0%,var(--hero-end) 100%);color:#fff;padding:80px 24px 60px;text-align:center;}\n.hero .eyebrow{display:inline-block;font-size:14px;color:#6ee7b7;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:14px;}\n.hero h1{font-size:36px;margin:0 0 16px;line-height:1.3;font-weight:800;}\n.hero p{color:#d1fae5;font-size:18px;max-width:640px;margin:0 auto;line-height:1.6;}\n.hero img{width:100%;max-width:640px;height:auto;margin:32px auto 0;border-radius:10px;display:block;}\narticle{padding-top:48px;}\narticle h2{font-size:26px;margin:56px 0 20px;padding-left:14px;border-left:5px solid var(--color-accent);line-height:1.4;}\narticle h3{font-size:19px;margin:32px 0 12px;color:var(--color-primary);}\narticle p{margin:16px 0;}\narticle strong{color:var(--color-primary);font-weight:700;}\narticle code{background:#d1fae5;padding:2px 8px;border-radius:4px;font-family:'SF Mono',Menlo,Consolas,monospace;font-size:14px;color:#065f46;}\n.databox{background:#d1fae5;border-left:4px solid var(--color-accent);padding:16px 20px;margin:24px 0;border-radius:0 8px 8px 0;font-size:15.5px;}\n.databox strong{color:var(--color-primary);}\n.warnbox{background:linear-gradient(135deg,#fef3c7 0%,#fde68a 100%);padding:16px 20px;margin:24px 0;border-radius:8px;font-size:15.5px;}\n.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:22px 0;}\ntable{width:100%;border-collapse:collapse;font-size:15px;background:var(--color-bg-card);}\nth,td{padding:11px 12px;text-align:left;border-bottom:1px solid #e2e8f0;vertical-align:top;}\nth{background:#f1f5f9;font-weight:700;color:#0f172a;}\ntd:first-child,th:first-child{font-weight:700;}\n@media (max-width:560px){.tablewrap table,.tablewrap thead,.tablewrap tbody,.tablewrap tr,.tablewrap th,.tablewrap td{display:block;width:auto;}.tablewrap thead{display:none;}.tablewrap tr{margin:0 0 14px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden;}.tablewrap td{border:none;border-bottom:1px solid #f1f5f9;padding:9px 14px;}.tablewrap td:first-child{background:#f1f5f9;font-weight:800;font-size:15.5px;}.tablewrap td:last-child{border-bottom:none;}.tablewrap td[data-label]::before{content:attr(data-label) \" \u2014 \";font-weight:700;color:var(--color-primary);}}\n.code-block{background:#0f172a;color:#e2e8f0;padding:16px 20px;border-radius:8px;font-family:'SF Mono',Menlo,Consolas,monospace;font-size:14px;line-height:1.6;margin:20px 0;overflow-x:auto;white-space:pre;}\n.cta{background:linear-gradient(135deg,#059669 0%,#10b981 100%);color:#fff;padding:28px 24px;border-radius:12px;margin:48px 0 0;text-align:center;}\n.cta h3{color:#fff;margin:0 0 8px;font-size:20px;}\n.cta p{color:#d1fae5;margin:0;font-size:15.5px;}\n.footer-nav{margin-top:32px;padding-top:20px;border-top:1px solid #e2e8f0;font-size:14px;color:var(--color-text-muted);}\n.footer-nav a{color:var(--color-primary);text-decoration:none;}\n@media (max-width:480px){.hero h1{font-size:26px;}.hero p{font-size:16px;}article h2{font-size:21px;}article h3{font-size:17px;}body{font-size:16px;}}\n<\/style>\n<section class=\"hero\">\n  <span class=\"eyebrow\">Node.js \uad50\uc7ac \u00b7 6\ud3b8 \u00b7 \ud30c\uc77c \ub2e4\ub8e8\uae30<\/span>\n  <h1>fs \ubaa8\ub4c8 \u2014 \ud30c\uc77c \uc77d\uae30\u00b7\uc4f0\uae30, \ub3d9\uae30 vs \ube44\ub3d9\uae30<\/h1>\n  <p>\ube0c\ub77c\uc6b0\uc800\uac00 \ub9c9\uc544\ub454 \uc601\uc5ed. Node \uac00 \uac00\uc7a5 \ube5b\ub098\ub294 \ub3c4\uad6c fs \ub97c \uc190\uc5d0 \uc775\ud788\uc790.<\/p>\n  <img decoding=\"async\" src=\"https:\/\/junai.ai\/blog\/wp-content\/uploads\/2026\/05\/hero-5-57.jpg\" alt=\"\ub3d9\uae30\uc640 \ube44\ub3d9\uae30 \ud30c\uc77c I\/O \uac00 \ub098\ub780\ud788 \ud750\ub974\ub294 \ucee8\uc149 \uc544\uc774\uc18c\uba54\ud2b8\ub9ad \uc77c\ub7ec\uc2a4\ud2b8\">\n<\/section>\n\n<div class=\"container\">\n<article>\n\n<p>\ub4dc\ub514\uc5b4 Node \uc758 \uc9c4\uc9dc \ubb34\ub300 \u2014 <strong>\ud30c\uc77c \uc2dc\uc2a4\ud15c<\/strong>. \ube0c\ub77c\uc6b0\uc800 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\ub294 \ubcf4\uc548 \ub54c\ubb38\uc5d0 \ud30c\uc77c\uc5d0 \uc811\uadfc \ubabb \ud55c\ub2e4. Node \ub294 \ub9c9\ud798\uc774 \uc5c6\ub2e4. \uadf8\ub798\uc11c \uc790\ub3d9\ud654 \uc2a4\ud06c\ub9bd\ud2b8\u00b7\uc815\uc801 \uc0ac\uc774\ud2b8 \ube4c\ub354\u00b7CLI \ub3c4\uad6c\uac00 \ub2e4 Node \ub85c \ub9cc\ub4e4\uc5b4\uc84c\ub2e4.<\/p>\n\n<p>\uad00\ubb38\uc740 <code>fs<\/code> \ubaa8\ub4c8 \ud55c \uac00\uc9c0. \uc774 \ubaa8\ub4c8\uc740 \uac19\uc740 \ub3d9\uc791\uc5d0 \ub300\ud574 <strong>3\uac00\uc9c0 API<\/strong> \ub97c \uc81c\uacf5\ud55c\ub2e4. \ub3d9\uae30\u00b7\ube44\ub3d9\uae30 \ucf5c\ubc31\u00b7Promise. \uc5b4\ub290 \uac78 \uace8\ub77c\uc57c \ud558\ub294\uc9c0 \ud5f7\uac08\ub9ac\ub2c8, \uc774\ubc88 \ud3b8\uc5d0\uc11c \uc815\ub9ac.<\/p>\n\n<h2>1. 3\uac00\uc9c0 API \u2014 \uac19\uc740 \ub3d9\uc791 \uc138 \uac00\uc9c0 \ubaa8\uc591<\/h2>\n\n<p>\uac19\uc740 &#8220;\ud30c\uc77c \uc77d\uae30&#8221; \ub3d9\uc791\uc774 \uc138 \uac00\uc9c0 \ud615\ud0dc\ub85c \uc874\uc7ac\ud55c\ub2e4.<\/p>\n\n<div class=\"code-block\">import fs from &#8216;node:fs&#8217;;\nimport fsp from &#8216;node:fs\/promises&#8217;;\n\n\/\/ \u2460 \ub3d9\uae30 (Sync)\nconst data = fs.readFileSync(&#8216;.\/hello.txt&#8217;, &#8216;utf-8&#8217;);\n\n\/\/ \u2461 \ube44\ub3d9\uae30 \ucf5c\ubc31 (\uc61b \ubc29\uc2dd)\nfs.readFile(&#8216;.\/hello.txt&#8217;, &#8216;utf-8&#8217;, (err, data) =&gt; {\n  if (err) throw err;\n  console.log(data);\n});\n\n\/\/ \u2462 Promise (\ud604\uc7ac \uad8c\uc7a5)\nconst data = await fsp.readFile(&#8216;.\/hello.txt&#8217;, &#8216;utf-8&#8217;);<\/div>\n\n<p>\uacb0\uacfc\ub294 \uc14b \ub2e4 \uac19\uc9c0\ub9cc \u2014 <strong>\uc774\ubca4\ud2b8 \ub8e8\ud504\ub97c \uc5b4\ub5bb\uac8c \ub2e4\ub8e8\ub290\ub0d0<\/strong>\uac00 \ub2e4\ub974\ub2e4. \uadf8\ub798\uc11c \uc5b4\ub5a4 API \ub97c \uc4f0\ub294\uac00\uac00 \uc11c\ubc84 \uc131\ub2a5\uc744 \uc88c\uc6b0\ud55c\ub2e4.<\/p>\n\n<div class=\"tablewrap\">\n<table>\n<thead><tr><th>API<\/th><th>\ud328\ud0a4\uc9c0<\/th><th>\ub3d9\uc791<\/th><th>\uad8c\uc7a5<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\ub3d9\uae30<\/td><td data-label=\"\ud328\ud0a4\uc9c0\"><code>node:fs<\/code> \uc758 <code>...Sync<\/code><\/td><td data-label=\"\ub3d9\uc791\">\ud638\ucd9c \uc989\uc2dc \ub9c9\ud798. \ub05d\ub0a0 \ub54c\uae4c\uc9c0 \ub2e4\ub978 \uc77c X<\/td><td data-label=\"\uad8c\uc7a5\">\uc2a4\ud06c\ub9bd\ud2b8\u00b7CLI \uc2dc\uc791\u00b7\uc124\uc815 \uc77d\uae30<\/td><\/tr>\n<tr><td>\ucf5c\ubc31<\/td><td data-label=\"\ud328\ud0a4\uc9c0\"><code>node:fs<\/code> (Sync \uc5c6\ub294 \ud568\uc218)<\/td><td data-label=\"\ub3d9\uc791\">\ubc31\uadf8\ub77c\uc6b4\ub4dc \uc2dc\uc791 + \ub05d\ub098\uba74 \ucf5c\ubc31 \ud638\ucd9c<\/td><td data-label=\"\uad8c\uc7a5\">\ub808\uac70\uc2dc. \uc2e0\uaddc\ub294 \ube44\ucd94<\/td><\/tr>\n<tr><td>Promise<\/td><td data-label=\"\ud328\ud0a4\uc9c0\"><code>node:fs\/promises<\/code><\/td><td data-label=\"\ub3d9\uc791\">await \ub85c \ubc1b\uc74c. \ucf5c\ubc31\uacfc \uac19\uc740 \ube44\ub3d9\uae30<\/td><td data-label=\"\uad8c\uc7a5\">\uae30\ubcf8. \ubaa8\ub4e0 \uc2e0\uaddc \ucf54\ub4dc<\/td><\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n\n<h2>2. \uac00\uc7a5 \ub9ce\uc774 \uc4f0\ub294 \uba54\uc11c\ub4dc 6\uac00\uc9c0<\/h2>\n\n<p>\uc2e4\uc804\uc5d0\uc11c 99% \ub97c \ucc28\uc9c0\ud558\ub294 \ud568\uc218 6\uac1c. <code>node:fs\/promises<\/code> \uae30\ubc18\uc73c\ub85c \ubcf4\uba74 \ub41c\ub2e4.<\/p>\n\n<div class=\"code-block\">import fs from &#8216;node:fs\/promises&#8217;;\nimport path from &#8216;node:path&#8217;;\n\n\/\/ \uc77d\uae30\nconst text = await fs.readFile(&#8216;.\/hello.txt&#8217;, &#8216;utf-8&#8217;);\nconst bin = await fs.readFile(&#8216;.\/image.png&#8217;); \/\/ \uc778\ucf54\ub529 \uc5c6\uc73c\uba74 Buffer\n\n\/\/ \uc4f0\uae30 (\ub36e\uc5b4\uc4f0\uae30)\nawait fs.writeFile(&#8216;.\/out.txt&#8217;, &#8216;\uc548\ub155\\n&#8217;, &#8216;utf-8&#8217;);\n\n\/\/ \uc774\uc5b4\uc4f0\uae30 (append)\nawait fs.appendFile(&#8216;.\/log.txt&#8217;, `${new Date().toISOString()}\\n`);\n\n\/\/ \uc874\uc7ac \ud655\uc778 + \uba54\ud0c0 (\uc5c6\uc73c\uba74 throw)\nconst stat = await fs.stat(&#8216;.\/out.txt&#8217;);\nconsole.log(stat.size, stat.mtime);\n\n\/\/ \ub514\ub809\ud1a0\ub9ac \ub9cc\ub4e4\uae30 (\uc7ac\uadc0)\nawait fs.mkdir(&#8216;.\/build\/css&#8217;, { recursive: true });\n\n\/\/ \ub514\ub809\ud1a0\ub9ac \ubaa9\ub85d\nconst files = await fs.readdir(&#8216;.\/src&#8217;);\nconsole.log(files); \/\/ [&#8216;index.js&#8217;, &#8216;utils.js&#8217;, &#8230;]<\/div>\n\n<p>\ubaa8\ub4e0 \ud568\uc218\ub294 <strong>\uc2e4\ud328\ud558\uba74 throw<\/strong>. <code>try\/catch<\/code> \ub610\ub294 <code>.catch()<\/code> \ub85c \uac10\uc2f8\uc790. \ucf5c\ubc31 API \uc758 <code>(err, data) =&gt; \u2026<\/code> \ud615\ud0dc\ub294 \uc61b\ub0a0 \ubc29\uc2dd.<\/p>\n\n<div class=\"databox\">\n<strong>\uc778\ucf54\ub529 \uc635\uc158<\/strong> \u2014 <code>readFile<\/code> \ub450 \ubc88\uc9f8 \uc778\uc790\uac00 \uc778\ucf54\ub529. <code>'utf-8'<\/code> \uc8fc\uba74 \ubb38\uc790\uc5f4, \uc548 \uc8fc\uba74 <code>Buffer<\/code> (\ubc14\uc774\ub108\ub9ac). \uc774\ubbf8\uc9c0\u00b7PDF \uac19\uc740 \ubc14\uc774\ub108\ub9ac\ub294 \uc778\ucf54\ub529 \uc5c6\uc774 \ubc1b\uc544 \uadf8\ub300\ub85c \ub2e4\ub978 \ud568\uc218\uc5d0 \uc804\ub2ec.\n<\/div>\n\n<h2>3. \ub3d9\uae30 API \ub294 \uc5b8\uc81c \uc4f0\ub098 \u2014 \ub450 \uac00\uc9c0 \ucf00\uc774\uc2a4\ub9cc<\/h2>\n\n<p>\ube44\ub3d9\uae30\uac00 \uae30\ubcf8\uc774\uc9c0\ub9cc, \ub3d9\uae30 (<code>...Sync<\/code>) \uac00 \uc633\uc740 \uacbd\uc6b0 \ub450 \uac00\uc9c0.<\/p>\n\n<h3>\u2460 \ud504\ub85c\uc138\uc2a4 \uc2dc\uc791 \uc2dc \uc124\uc815 \uc77d\uae30<\/h3>\n\n<p>\uc11c\ubc84\uac00 \uc77c\uc744 \uc2dc\uc791\ud558\uae30 <strong>\uc804<\/strong>\uc5d0 \ud544\uc694\ud55c \uc124\uc815. \uc5b4\ucc28\ud53c \uc774\uac8c \ub05d\ub098\uc57c \ub2e4\uc74c\uc774 \uc758\ubbf8\uac00 \uc788\ub2e4.<\/p>\n\n<div class=\"code-block\">\/\/ server-start.js\nimport fs from &#8216;node:fs&#8217;;\n\nconst config = JSON.parse(\n  fs.readFileSync(&#8216;.\/config.json&#8217;, &#8216;utf-8&#8217;)\n);\nconst app = createApp(config);\napp.listen(config.port);<\/div>\n\n<p>\uc5ec\uae30\uc11c \ube44\ub3d9\uae30\ub97c \uc4f0\uba74 \ucf54\ub4dc \ud750\ub984\ub9cc \ubcf5\uc7a1\ud574\uc9c0\uace0 \uc5bb\ub294 \uac8c \uc5c6\ub2e4. \uc5b4\ucc28\ud53c \uc11c\ubc84\ub294 \uc124\uc815 \uc5c6\uc774 \uc2dc\uc791 \ubabb \ud568.<\/p>\n\n<h3>\u2461 \uc9e7\uc740 CLI \uc2a4\ud06c\ub9bd\ud2b8<\/h3>\n\n<p>\ud55c \ubc88 \ub3cc\uace0 \ub05d\ub098\ub294 \uc790\ub3d9\ud654 \uc2a4\ud06c\ub9bd\ud2b8. \ub3d9\uc2dc \uc694\uccad\uc774 \uc5c6\uc73c\ubbc0\ub85c \ub9c9\ud600\ub3c4 \uc190\ud574 \uc5c6\uc74c.<\/p>\n\n<div class=\"code-block\">\/\/ rename-all.js \u2014 \ub514\ub809\ud1a0\ub9ac \uc548 \ud30c\uc77c \uc774\ub984 \uc77c\uad04 \ubcc0\uacbd\nimport fs from &#8216;node:fs&#8217;;\nimport path from &#8216;node:path&#8217;;\n\nconst dir = process.argv[2];\nconst files = fs.readdirSync(dir);\nfor (const f of files) {\n  const ext = path.extname(f);\n  const base = path.basename(f, ext);\n  fs.renameSync(\n    path.join(dir, f),\n    path.join(dir, `${base}-new${ext}`)\n  );\n}<\/div>\n\n<p>\uc774\ub7f0 1\ud68c\uc131 \uc2a4\ud06c\ub9bd\ud2b8\ub294 \ub3d9\uae30\uac00 \uc77d\uae30 \uc26c\uc6cc\uc11c \ub354 \ub0ab\ub2e4. await \uc904\uc904\uc774 \ub098\uc5f4\ud560 \ud544\uc694 \uc5c6\uc74c.<\/p>\n\n<h2>4. \uc11c\ubc84\uc5d0\uc120 \uc808\ub300 \ub3d9\uae30\ub97c \uc4f0\uc9c0 \ub9c8\ub77c<\/h2>\n\n<p>\uac00\uc7a5 \ud070 \ud568\uc815. HTTP \uc11c\ubc84\uc758 \uc694\uccad \ud578\ub4e4\ub7ec \uc548\uc5d0\uc11c <code>readFileSync<\/code> \ub97c \ud638\ucd9c\ud558\uba74 \uc5b4\ub5a4 \uc77c\uc774?<\/p>\n\n<div class=\"warnbox\">\n<strong>\uc2e4\uc81c \uc601\ud5a5<\/strong> \u2014 Node \ub294 \ub2e8\uc77c \uc2a4\ub808\ub4dc \uc774\ubca4\ud2b8 \ub8e8\ud504. <code>readFileSync<\/code> \uac00 10ms \uac78\ub9ac\uba74 <strong>\uadf8 10ms \ub3d9\uc548 \ub2e4\ub978 \ubaa8\ub4e0 \uc694\uccad\uc774 \uba48\ucd98\ub2e4<\/strong>. 1000 RPS \ubd80\ud558\ub77c\uba74 \ub204\uc801 \uc9c0\uc5f0\uc774 \ud3ed\ubc1c\ud55c\ub2e4. \uc61b Pages Router \uc2dc\uc808 <code>getServerSideProps<\/code> \uc548\uc5d0 \ub3d9\uae30 fs \ubc15\uc740 \uc0ac\ub840\uac00 \uac00\uc7a5 \ud754\ud55c \uc0ac\uace0. \uc774\ub798\uc11c \ube44\ub3d9\uae30\uac00 \uae30\ubcf8\uc778 \uac83.\n<\/div>\n\n<p>\uc11c\ubc84 \ucf54\ub4dc\uc5d0\uc120 \ubb34\uc870\uac74 <code>node:fs\/promises<\/code> \uc758 <code>await<\/code> \ud615\ud0dc. \uc758\uc2dd\ud558\uc9c0 \uc54a\uc544\ub3c4 \ub418\ub3c4\ub85d <strong>\ucc98\uc74c\ubd80\ud130 <code>fs\/promises<\/code> \ub9cc import<\/strong> \ud558\ub294 \uc2b5\uad00\uc744 \ub4e4\uc774\uc790.<\/p>\n\n<h2>5. \ud754\ud55c \ud328\ud134 \u2014 \uc874\uc7ac \ud655\uc778 + \uc548\uc804\ud55c \uc4f0\uae30<\/h2>\n\n<p>\uc2e4\uc804\uc5d0\uc11c \uc790\uc8fc \ub9cc\ub098\ub294 \ub450 \ud328\ud134.<\/p>\n\n<h3>\uc874\uc7ac\ud558\uba74 \uc77d\uace0 \uc5c6\uc73c\uba74 \uc0dd\uc131<\/h3>\n\n<div class=\"code-block\">import fs from &#8216;node:fs\/promises&#8217;;\n\nasync function readOrInit(file, defaults) {\n  try {\n    return JSON.parse(await fs.readFile(file, &#8216;utf-8&#8217;));\n  } catch (e) {\n    if (e.code === &#8216;ENOENT&#8217;) {\n      await fs.writeFile(file, JSON.stringify(defaults, null, 2));\n      return defaults;\n    }\n    throw e;\n  }\n}\n\nconst settings = await readOrInit(&#8216;.\/settings.json&#8217;, { theme: &#8216;dark&#8217; });<\/div>\n\n<p><code>e.code === 'ENOENT'<\/code> \uac00 &#8220;\ud30c\uc77c \uc5c6\uc74c&#8221; \uc758 \ud45c\uc900 \uc5d0\ub7ec \ucf54\ub4dc. <code>fs.exists<\/code> \uac19\uc740 \ubcc4\ub3c4 \ud568\uc218 \uc4f0\uc9c0 \ub9d0\uace0 try\/catch \ud328\ud134\uc774 \ud45c\uc900\uc774\ub2e4 (exists \ub294 race condition \uc774 \uc788\uc5b4 deprecated).<\/p>\n\n<h3>\uc784\uc2dc \ud30c\uc77c \u2192 \ubcf8 \ud30c\uc77c \uad50\uccb4 (\uc6d0\uc790\uc801 \uc4f0\uae30)<\/h3>\n\n<div class=\"code-block\">async function atomicWrite(file, data) {\n  const tmp = `${file}.tmp.${Date.now()}`;\n  await fs.writeFile(tmp, data, &#8216;utf-8&#8217;);\n  await fs.rename(tmp, file); \/\/ \uc6d0\uc790\uc801 \uad50\uccb4\n}<\/div>\n\n<p>\uc4f0\uae30 \ub3c4\uc911 \ud504\ub85c\uc138\uc2a4\uac00 \uc8fd\uc5b4\ub3c4 \uc6d0\ubcf8\uc740 \uc548\uc804. \ub370\uc774\ud130 \uc800\uc7a5\uc774 \uc911\uc694\ud55c \uacbd\uc6b0 \ud45c\uc900 \ud328\ud134.<\/p>\n\n<h3>\uc694\uc57d \u2014 6\ud3b8 \uc88c\ud45c<\/h3>\n\n<p>\uc5ec\uae30\uae4c\uc9c0 \uc815\ub9ac. <code>fs<\/code> \ub294 3\uac00\uc9c0 API \u2014 \ub3d9\uae30(<code>...Sync<\/code>) \u00b7 \ucf5c\ubc31 \u00b7 Promise. <strong>\ud604\uc7ac \ud45c\uc900\uc740 <code>node:fs\/promises<\/code> + <code>await<\/code><\/strong>. \ub3d9\uae30\ub294 \ud504\ub85c\uc138\uc2a4 \uc2dc\uc791 \uc124\uc815\uacfc 1\ud68c\uc131 \uc2a4\ud06c\ub9bd\ud2b8\uc5d0\ub9cc, \uc11c\ubc84 \ud578\ub4e4\ub7ec\uc5d4 \uc808\ub300 \uae08\uc9c0. \uc790\uc8fc \uc4f0\ub294 \uba54\uc11c\ub4dc\ub294 <code>readFile<\/code>\u00b7<code>writeFile<\/code>\u00b7<code>appendFile<\/code>\u00b7<code>stat<\/code>\u00b7<code>mkdir<\/code>\u00b7<code>readdir<\/code> 6\uac1c. \uc874\uc7ac \ud655\uc778\uc740 try\/catch + ENOENT \ud328\ud134, \uc911\uc694 \ub370\uc774\ud130\ub294 \uc784\uc2dc \ud30c\uc77c \u2192 rename \uc6d0\uc790\uc801 \uc4f0\uae30. \ub2e4\uc74c \ud3b8\uc5d0\uc120 <strong>path \uc640 os \ubaa8\ub4c8<\/strong>\ub85c \uacbd\ub85c \ub2e4\ub8e8\uae30.<\/p>\n\n<div class=\"cta\">\n<h3>\ub2e4\uc74c \ud3b8 \uc608\uace0 \u2014 path\uc640 os \ubaa8\ub4c8<\/h3>\n<p>\ud06c\ub85c\uc2a4 \ud50c\ub7ab\ud3fc \uacbd\ub85c \ub2e4\ub8e8\uae30\uc640 \uc2dc\uc2a4\ud15c \uc815\ubcf4 \uc77d\uae30. 7\ud3b8.<\/p>\n<\/div>\n\n<div class=\"footer-nav\">\n\uc2dc\ub9ac\uc988 \u00b7 <a href=\"https:\/\/junai.ai\/blog\/category\/nodejs\/\">\uc27d\uac8c \ubc30\uc6b0\ub294 Node.js<\/a> \u00b7 \uc774\uc804: <a href=\"https:\/\/junai.ai\/blog\/nodejs-npm-package-json-5\/\">Ch.5 npm \uacfc package.json<\/a>\n<\/div>\n\n<\/article>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Node.js fs \ubaa8\ub4c8\ub85c \ud30c\uc77c \uc77d\uace0 \uc4f0\uae30. \ub3d9\uae30\u00b7\ube44\ub3d9\uae30\u00b7promises API \uc138 \ubc29\uc2dd\uc758 \ucc28\uc774\uc640 \uc5b8\uc81c \ubb34\uc5c7\uc744 \uc4f0\ub098. \uc790\uc8fc \uc4f0\ub294 \uba54\uc11c\ub4dc \uc815\ub9ac. \uad50\uc7ac 6\ud3b8.<\/p>\n","protected":false},"author":1,"featured_media":824,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-878","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nodejs"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":0,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/media\/824"}],"wp:attachment":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}