Skip to content

Commit 13bb537

Browse files
authored
Merge pull request #372 from ut-code/add-writefilesync-answer
Add answer for `fs.writeFileSync`
2 parents e807a28 + e99d6ce commit 13bb537

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/3-web-servers/03-module/_samples/write-with-fs/main.mjs renamed to docs/3-web-servers/03-module/_samples/write-file-sync/main.mjs

File renamed without changes.

docs/3-web-servers/03-module/index.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,18 @@ Hello World
168168

169169
[`fs.writeFileSync` 関数](https://nodejs.org/api/fs.html#fswritefilesyncfile-data-options)を用いて、ファイルに文字列を書き出してみましょう。
170170

171-
<ViewSource url={import.meta.url} path="_samples/fs-writeFileSync" noCodeSandbox />
171+
<Answer>
172+
173+
第一引数にファイル名、第二引数に書き込む文字列を指定します。
174+
175+
```javascript title=main.mjs
176+
import { writeFileSync } from "fs";
177+
writeFileSync("./sample.txt", "Hello World");
178+
```
179+
180+
<ViewSource url={import.meta.url} path="_samples/write-file-sync" noCodeSandbox />
181+
182+
</Answer>
172183

173184
## npm
174185

0 commit comments

Comments
 (0)