writeFile
Write UTF-8 text to a file.
js
writeFile(path, content)Arguments
| Argument | Type | Meaning |
|---|---|---|
path | string | File path. |
content | string | Text to write. |
Returns
null on success; error string on failure.
Example
js
const error = writeFile(__dirname + "/result.json", JSON.stringify({ok: true}));
if (error !== null) throw new Error(error);Notes
Native file helpers do not resolve relative paths like require(); use __dirname or scriptsDir().