# node:vm

The `node:vm` module compiles and runs JavaScript code inside virtual machine contexts, as the [Node.js vm documentation](https://nodejs.org/api/vm.html) 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)` |

---

## Related resources

- [Node.js APIs](/en/documentation/devtools/runtime/node.md): Every Node.js module Azion Runtime resolves, and how each one behaves.
- [Use Node.js APIs through polyfills](/en/documentation/guides/application-development/functions-and-runtime/use-polyfills.md): How the build resolves Node.js APIs through polyfills, shown in a JavaScript project.
- [node:module](/en/documentation/devtools/runtime/node/module.md): The module system APIs, and which of their members a function can call.
- [Web standards](/en/documentation/devtools/runtime/api-reference/web-standards.md): The JavaScript standards Azion Runtime follows, and the code forms it refuses.
