node:vm
The node:vm module in Azion Runtime: the members it exports, and the error each code-running method throws inside a function.
The node:vm module compiles and runs JavaScript code inside virtual machine contexts, as the Node.js vm documentation describes. In Azion Runtime, import vm from "node:vm" builds and loads, in a deployed function and under azion dev. The module exports Script, compileFunction, constants, createContext, createScript, isContext, measureMemory, runInContext, runInNewContext, and runInThisContext.
The methods that run code in a context, runInThisContext, runInNewContext, runInContext, and Script.runInThisContext, throw an Error instead of running it. The message is the same in a deployed function and under azion dev.
Methods
The table lists each method that runs code in a context, and the error it throws:
| Call | Result |
|---|---|
vm.runInThisContext(code) | Throws Error: [unenv] vm.runInThisContext is not implemented yet! |
vm.runInNewContext(code, context) | Throws Error: [unenv] vm.runInNewContext is not implemented yet! |
vm.runInContext(code, context) | Throws Error: [unenv] vm.runInContext is not implemented yet! with a context that vm.createContext() returned |
script.runInThisContext() | Throws Error: [unenv] Script.runInThisContext is not implemented yet! on a script built with new vm.Script(code) |