# node:fs

The `node:fs` module is the Node.js file system API. Node.js applications use it for file input and output (I/O): reading, writing, updating, and deleting files and directories. In Azion Runtime, `import fs from "node:fs"` builds, but a deployed function cannot write files with it, and its `fs` object exposes 8 members.

Synchronous reads go to an in-memory file system that the build fills from the `build.memoryFS` setting of [azion.config.js](/en/documentation/devtools/cli/azion-config-js/). A relative path resolves from the root, so `./hello.txt` is read as `/hello.txt`. A path the build did not embed throws an `ENOENT` error.

> **Note**
>
> Under `azion dev`, `fs` paths resolve under the `.edge/storage/` folder of the project, `fs.writeFileSync` is not a function, and the `fs` object exposes 40 members.

---

## Methods

The table lists what each call returns or throws in a deployed function, on paths the build did not embed:

| Call                                                             | Result in a deployed function                                                                  |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `fs.readFileSync('./hello.txt')`                                 | Throws `Error: ENOENT: no such file or directory, fs.readFileSync call for path '/hello.txt'`. |
| `fs.writeFileSync('/tmp/my-file.txt', 'x')`                      | Throws `Error: unsupported`. A later `fs.readFileSync` of the same path throws `ENOENT`.       |
| `fs.existsSync('/')`                                             | Returns `false`.                                                                               |
| `fs.readFile('./hello.txt', callback)`                           | Passes `Error: missing storage annotation: readfile './hello.txt'` to the callback.            |
| `readFile('./hello.txt')` from `node:fs/promises`                | Rejects with `Error: missing storage annotation: readfile './hello.txt'`.                      |
| `writeFile('/tmp/my-file.txt', 'hello')` from `node:fs/promises` | Rejects with `Error: missing storage annotation`.                                              |
| `readdir('/')` from `node:fs/promises`                           | Rejects with `Error: missing storage annotation: readdir '/'`.                                 |
| `stat('/')` from `node:fs/promises`                              | Rejects with `Error: missing storage annotation: stat '/'`.                                    |

---

## Related resources

- [Node.js APIs](/en/documentation/devtools/runtime/node.md): The Node.js modules Azion Runtime resolves, with the behavior of each one.
- [azion.config.js](/en/documentation/devtools/cli/azion-config-js.md): The `build.memoryFS` keys that set which folders the build injects into the in-memory file system.
- [Object Storage API](/en/documentation/devtools/runtime/api-reference/storage.md): The runtime API a function uses to read and write objects in a bucket.
- [Use Node.js APIs through polyfills](/en/documentation/guides/application-development/functions-and-runtime/use-polyfills.md): How the build resolves Node.js APIs through polyfills in a JavaScript project.
