# Azion Runtime and Node.js API compatibility

import DocButton from '~/components/webkit/DocButton.vue';

## Node.js APIs supported in Azion Runtime

The compatibility between **Azion Runtime** and **Node.js** is an ongoing task, but a set of Node Runtime APIs are listed and compatible with Azion Runtime. The following list of APIs can be imported inside functions with the standard import syntax:

```js
import { API } from "import-origin";
```

| API | Support Level | Code sample  | Comments |
|---------|---------------|----------|-------------|
| async_hooks | 🟡 Partially supported | [Access code sample](https://github.com/aziontech/azion-samples/tree/dev/samples/node-async-hooks) | Only [AsyncLocalStorage](https://nodejs.org/api/async_context.html#class-asynclocalstorage) and [AsyncResource](https://nodejs.org/api/async_hooks.html#class-asyncresource) are implemented. |
| fs | 🟡 Partially supported | | Only async methods ([check the list below](#fs-support)), others through [polyfills](#node-polyfills). |
| module | 🟡 Partially supported | | Also supported in local dev through polyfills ([check table below](#node-polyfills)). |
| process.env | 🟢 Supported Supported | `process.env.VAR_NAME`| Other features supported through polyfills ([check table below](#node-polyfills)). |
| url | 🟡 Partially supported | | Only global `URL` and `URLSearchParams`. |

### File System (FS) module support

The Azion Runtime provides native support for the File System (FS) module, allowing you to interact with the file system within your functions.

 Async:

| Method                          | Parameters                                   | Description                                          |
|---------------------------------|----------------------------------------------|-----------------------------------------------------|
| `fs.lstat`                      | `path`, `options` (optional), `callback`   | Gets information about the file or directory.      |
| `fs.mkdir`                      | `path`, `options` (optional), `callback`   | Creates a directory.                                |
| `fs.stat`                       | `path`, `options` (optional), `callback`   | Gets information about the file or directory.      |
| `fs.writeFile`                 | `file`, `data`, `options` (optional), `callback` | Writes data to a file.                             |
| `fs.readFile`                  | `path`, `options` (optional), `callback`   | Reads the contents of a file.                       |
| `fs.readdir`                   | `path`, `options` (optional), `callback`   | Reads the contents of a directory.                  |
| `fs.writeFileSync`             | `file`, `data`, `options` (optional)       | Writes data to a file synchronously.                |
| `fs.rename`                     | `oldPath`, `newPath`, `callback`           | Renames a file or directory.                        |
| `fs.realpath`                  | `path`, `options` (optional), `callback`   | Resolves the absolute path of a file.              |
| `fs.copyFile`                  | `src`, `dest`, `mode` (optional), `callback` | Copies a file.                                      |
| `fs.cp`                        | `src`, `dest`, `options` (optional), `callback` | Copies files and directories.                       |
| `fs.read`                      | `fd`, `buffer`, `offset`, `length`, `position`, `callback` | Reads data from a file.                             |
| `fs.read`                      | `fd`, `buffer`, `options` (optional), `callback` | Reads data from a file.                             |
| `fs.read`                      | `fd`, `options` (optional), `callback`     | Reads data from a file.                             |
| `fs.rmdir`                     | `path`, `options` (optional), `callback`   | Removes a directory.                                |
| `fs.utimes`                    | `path`, `atime`, `mtime`, `callback`       | Updates the access and modification times of a file. |

---

## Supported Node APIs with polyfills

A polyfill is a code snippet, often used in JavaScript, that brings new features to environments lacking these capabilities. Polyfills are used during build time at Azion and can be configured through the [azion.config.js](/en/documentation/devtools/cli/configs/azion-config-js/) file.

The following Node APIs are supported through polyfills, along with their respective supported methods.

**Status legend:**

- 🟢 **Supported**: the API works normally at runtime.
- 🟡 **Partially supported**: only some methods or features are available.
- 🔴 **Build-only**: the module is included so the build process completes without errors, but API calls do not work at runtime.

:::note[About the Azion Cells runtime environment]
Functions on Azion run inside **Cells**, an isolation environment based on **V8 Isolates**. Each Cell is a lightweight, secure execution context with no direct access to the underlying operating system.

For multi-tenant security and infrastructure integrity reasons, Cells do not allow:

- Access to operating system properties (such as hostname, platform, or CPU/memory information via `node:os`).
- DNS resolution via native system calls (`node:dns`, `node:dns/promises`).
- Creation of low-level TCP/UDP sockets that require direct syscalls.

Modules marked as 🔴 **Build-only** are included as stubs to ensure that NPM packages with static dependencies on these modules can be compiled. Calls to these modules at runtime produce no results and may return default values or throw silent errors.
:::

| Module                | Status |
|-----------------------|--------|
| _http_agent           | 🟡 Partially supported     |
| _http_client          | 🟡 Partially supported     |
| _http_common          | 🟡 Partially supported     |
| _http_incoming        | 🟡 Partially supported     |
| _http_outgoing        | 🟡 Partially supported     |
| _http_server          | 🟡 Partially supported     |
| _stream_duplex        | 🟡 Partially supported     |
| _stream_passthrough   | 🟡 Partially supported     |
| _stream_readable      | 🟡 Partially supported     |
| _stream_transform      | 🟡 Partially supported     |
| _stream_wrap          | 🟡 Partially supported     |
| _stream_writable      | 🟡 Partially supported     |
| _tls_common           | 🟡 Partially supported     |
| _tls_wrap             | 🟡 Partially supported     |
| [assert](#)          | 🟡 Partially supported     |
| assert/strict         | 🟡 Partially supported     |
| [async_hooks](/en/documentation/products/azion-edge-runtime/compatibility/node/async-hooks/)     | 🟢 Supported     |
| [buffer](/en/documentation/products/azion-edge-runtime/compatibility/node/buffer/)          | 🟡 Partially supported     |
| child_process    | 🟡 Partially supported     |
| cluster          | 🟢 Supported     |
| console          | 🟢 Supported     |
| constants        | 🟢 Supported     |
| [crypto](/en/documentation/products/azion-edge-runtime/compatibility/node/crypto/)          | 🟡 Partially supported     |
| dgram           | 🟢 Supported     |
| diagnostics_channel | 🟢 Supported     |
| dns             | 🔴 Build-only     |
| dns/promises    | 🔴 Build-only     |
| domain          | 🟢 Supported     |
| [events](/en/documentation/products/azion-edge-runtime/compatibility/node/events/)          | 🟢 Supported     |
| [fs](/en/documentation/products/azion-edge-runtime/compatibility/node/fs/)              | 🟡 Partially supported     |
| fs/promises     | 🟡 Partially supported     |
| [http](/en/documentation/products/azion-edge-runtime/compatibility/node/http/)            | 🟡 Partially supported     |
| http2           | 🟡 Partially supported     |
| https           | 🟡 Partially supported     |
| inspector       | 🟢 Supported     |
| inspector/promises    | 🟡 Partially supported     |
| [module](/en/documentation/products/azion-edge-runtime/compatibility/node/module/)          | 🟡 Partially supported     |
| net             | 🟡 Partially supported     |
| [os](/en/documentation/products/azion-edge-runtime/compatibility/node/os/)              | 🔴 Build-only     |
| [path](/en/documentation/products/azion-edge-runtime/compatibility/node/path/)            | 🟢 Supported     |
| path/posix            | 🟡 Partially supported     |
| path/win32           | 🟡 Partially supported     |
| perf_hooks     | 🟢 Supported     |
| [process](/en/documentation/products/azion-edge-runtime/compatibility/node/process/)         | 🟡 Partially supported     |
| punycode             | 🟡 Partially supported     |
| querystring          | 🟡 Partially supported     |
| readline        | 🟢 Supported     |
| readline/promises | 🟢 Supported     |
| repl                  | 🟡 Partially supported     |
| [stream](/en/documentation/products/azion-edge-runtime/compatibility/node/stream/)          | 🟡 Partially supported     |
| stream/consumers      | 🟡 Partially supported     |
| stream/promises       | 🟡 Partially supported     |
| stream/web           | 🟢 Supported     |
| [string_decoder](/en/documentation/products/azion-edge-runtime/compatibility/node/string-decoder/)  | 🟢 Supported     |
| sys                   | 🟡 Partially supported     |
| [timers](/en/documentation/products/azion-edge-runtime/compatibility/node/timers/)          | 🟡 Partially supported     |
| timers/promises | 🟢 Supported     |
| tls             | 🟡 Partially supported     |
| trace_events    | 🟢 Supported     |
| tty             | 🟢 Supported     |
| [url](/en/documentation/products/azion-edge-runtime/compatibility/node/url/)             | 🟢 Supported     |
| [util](/en/documentation/products/azion-edge-runtime/compatibility/node/utils/)            | 🟡 Partially supported     |
| util/types           | 🟡 Partially supported     |
| v8              | 🟢 Supported     |
| [vm](/en/documentation/products/azion-edge-runtime/compatibility/node/vm/)              | 🟢 Supported     |
| wasi            | 🟢 Supported     |
| worker_threads  | 🟡 Partially supported     |
| [zlib](/en/documentation/products/azion-edge-runtime/compatibility/node/zlib/)            | 🟢 Supported     |


:::note 
You can check the list of APIs resolved through polyfills in [Azion Bundler's repository](https://github.com/aziontech/bundler/blob/main/lib/build/bundlers/polyfills/polyfills-manager.js), as well as contribute with the project.
:::

For additional compatibility information:
<DocButton href="/en/documentation/runtime-apis/javascript/" label="Go To Supported Web APIs" kind="secondary" target="_blank" size="medium" />
<DocButton href="/en/documentation/products/devtools/azion-edge-runtime/frameworks-compatibility/" label="Go To Supported Web Frameworks" kind="secondary" target="_blank" size="medium" />