Node.js API compatibility - VM
Explore the integration and application of the Node.js VM module within the Azion Runtime. The VM module provides utilities to run JavaScript code in a virtualized environment, offering a level of isolation from the main application.
The vm module in Node.js provides a way to execute JavaScript code within a virtual machine context. This allows developers to run code in a sandboxed environment, which can be useful for various applications, such as executing user-generated code, testing, or isolating code execution from the main application. This module is available in the Azion Runtime through Node.js compatibility, where a common use case is evaluating dynamic snippets or templates inside a function while keeping them separated from the surrounding scope.
The example below shows how to use the vm module in a function: