Azion Runtime and Node.js API compatibility
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 edge functions with the standard import syntax:
import { API } from "import-origin";
API | Support Level | Code sample | Comments |
---|---|---|---|
async_hooks | 🟡 Partially supported Partially supported | Access code sample | Only AsyncLocalStorage and AsyncResource are implemented. |
fs | 🟡 Partially supported Partially supported | Only async methods (check the list below), others through polyfills. | |
module | 🟡 Partially supported Partially supported | Also supported in local dev through polyfills (check table below). | |
process.env | 🟢 Supported Supported | process.env.VAR_NAME | Other features supported through polyfills (check table below). |
url | 🟡 Partially supported 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 edge 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 file.
The following Node APIs are supported through polyfills, along with their respective supported methods.
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 | 🟢 Supported |
buffer | 🟡 Partially supported |
child_process | 🟡 Partially supported |
cluster | 🟢 Supported |
console | 🟢 Supported |
constants | 🟢 Supported |
crypto | 🟡 Partially supported |
dgram | 🟢 Supported |
diagnostics_channel | 🟢 Supported |
dns | 🟢 Supported |
dns/promises | 🟢 Supported |
domain | 🟢 Supported |
events | 🟢 Supported |
fs | 🟡 Partially supported |
fs/promises | 🟡 Partially supported |
http | 🟡 Partially supported |
http2 | 🟡 Partially supported |
https | 🟡 Partially supported |
inspector | 🟢 Supported |
inspector/promises | 🟡 Partially supported |
module | 🟡 Partially supported |
net | 🟡 Partially supported |
os | 🟢 Supported |
path | 🟢 Supported |
path/posix | 🟡 Partially supported |
path/win32 | 🟡 Partially supported |
perf_hooks | 🟢 Supported |
process | 🟡 Partially supported |
punycode | 🟡 Partially supported |
querystring | 🟡 Partially supported |
readline | 🟢 Supported |
readline/promises | 🟢 Supported |
repl | 🟡 Partially supported |
stream | 🟡 Partially supported |
stream/consumers | 🟡 Partially supported |
stream/promises | 🟡 Partially supported |
stream/web | 🟢 Supported |
string_decoder | 🟢 Supported |
sys | 🟡 Partially supported |
timers | 🟡 Partially supported |
timers/promises | 🟢 Supported |
tls | 🟡 Partially supported |
trace_events | 🟢 Supported |
tty | 🟢 Supported |
url | 🟢 Supported |
util | 🟡 Partially supported |
util/types | 🟡 Partially supported |
v8 | 🟢 Supported |
vm | 🟢 Supported |
wasi | 🟢 Supported |
worker_threads | 🟡 Partially supported |
zlib | 🟢 Supported |
For additional compatibility information:
Go To Supported Web APIs Go To Supported Web FrameworksContributors