Azion Runtime and Node.js API compatibility
Node built-in
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:
API | Support Level | Code sample | Comments |
---|---|---|---|
async_hooks | 🟡 Partially supported | Access code sample | Only AsyncLocalStorage and AsyncResource are implemented |
fs | 🟡 Partially supported | Only async methods (check the list below), others through polyfills | |
module | 🟡 Partially supported | Also supported in local dev through polyfills (check table below) | |
process.env | 🟢 Supported | process.env.VAR_NAME | Other features supported through polyfills (check table below) |
url | 🟡 Partially supported | Only global URL and URLSearchParams |
FS support
Async:
- fs.lstat(path[, options], callback)
- fs.mkdir(path[, options], callback)
- fs.stat(path[, options], callback)
- fs.writeFile(file, data[, options], callback)
- fs.readFile(path[, options], callback)
- fs.readdir(path[, options], callback)
- fs.writeFileSync(file, data[, options])
- fs.rename(oldPath, newPath, callback)
- fs.realpath(path[, options], callback)
- fs.copyFile(src, dest[, mode], callback)
- fs.cp(src, dest[, options], callback)
- fs.read(fd, buffer, offset, length, position, callback)
- fs.read(fd, buffer[, options], callback)
- fs.read(fd[, options], callback)
- fs.rmdir(path[, options], callback)
- fs.utimes(path, atime, mtime, callback)
Node 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.
Here’s a list of Node APIs supported through polyfills:
API | Support Level | Code sample |
---|---|---|
buffer | 🟡 Partially supported | Access code sample |
crypto | 🟡 Partially supported | Access code sample |
events | 🟡 Partially supported | Access code sample |
fs | 🟡 Partially supported | Access code sample |
http | 🟡 Partially supported | Access code sample |
module | 🟡 Partially supported | Access code sample |
os | 🟡 Partially supported | Access code sample |
path | 🟡 Partially supported | Access code sample |
process | 🟡 Partially supported | Access code sample |
stream | 🟡 Partially supported | Access code sample |
string_decoder | 🟡 Partially supported | Access code sample |
timers | 🟡 Partially supported | Access code sample |
url | 🟡 Partially supported | Access code sample |
util | 🟡 Partially supported | Access code sample |
vm | 🟡 Partially supported | Access code sample |
zlib | 🟡 Partially supported | Access code sample |
For additional compatibility information:
Go to supported Web APIs Go to supported Web Frameworks