ApplesauceOS
Read Markdown ↗Download .md

readFile

Read a UTF-8 text file.

js
readFile(path)

Arguments

ArgumentTypeMeaning
pathstringPrefer an absolute path.

Returns

Text string, or null on failure.

Example

js
const text = readFile(__dirname + "/config.json");
if (text === null) throw new Error("Cannot read config");
console.log(JSON.parse(text));

Notes

Native file helpers do not resolve relative paths like require(); use __dirname or scriptsDir().

All JavaScript APIs · Automation playbook