Deno Code
AI-generatedOverview
This node allows users to run custom TypeScript code within the Deno runtime environment directly inside an n8n workflow. It is designed for scenarios where you need to execute complex or custom logic that goes beyond standard node capabilities, leveraging the modern and secure Deno runtime.
Typical use cases include:
- Processing or transforming input data with custom scripts.
- Running code once for all input items collectively or individually per item.
- Utilizing Deno’s permissions system to control access to environment variables, network, filesystem, subprocesses, etc.
- Parallel or sequential execution of code on multiple input items to optimize performance or maintain order.
For example, you could write a script to fetch additional data from an API, perform advanced calculations, or manipulate JSON objects in ways not supported by built-in nodes.
Properties
| Name | Meaning |
|---|---|
| Mode | Determines how the code runs relative to input items: • Run Once for All Items: Executes the code a single time with all input items as an array. • Run Once for Each Item: Executes the code separately for each input item. |
| Processing | Controls execution style when running code for each item: • Sequential: Runs code one item at a time in order. • Parallel: Runs code simultaneously for all items, improving speed but without guaranteed order. |
| Deno TypeScript Code | The actual TypeScript code to be executed in the Deno runtime. This code can access the current item’s JSON data and other helper functions (some are planned but not yet implemented). |
| Permissions | Specifies which Deno runtime permissions to grant the code, such as: • Allow All • Allow reading environment variables • Allow high resolution timing • Allow network connections (including dynamic imports) • Allow reading/writing filesystem • Allow running subprocesses |
| --no-npm | Boolean flag indicating whether to configure the Deno CLI with the --no-npm option, affecting module resolution behavior. |
Output
The node outputs JSON data structured as follows:
When running once for each item, the output is an array where each element corresponds to the processed result of the respective input item. Each element contains a
jsonproperty with the returned data from the user’s Deno code. If an error occurs and "continue on fail" is enabled, the output includes anerrorfield describing the failure.When running once for all items, the output is a single JSON array containing the results of processing all input items collectively.
The node does not explicitly handle binary data output; it focuses on JSON results returned from the executed TypeScript code.
Dependencies
- Requires the Deno runtime executable to be available on the system path or at
/usr/bin/deno. - Uses a bundled Deno VM worker implementation to run the TypeScript code securely.
- No external API keys or services are required by default, but the user’s code may connect externally if granted appropriate permissions.
- Permissions must be configured carefully to allow necessary operations (e.g., network access, file read/write).
Troubleshooting
- Deno executable not found: The node expects the Deno binary to be accessible via the system PATH or at
/usr/bin/deno. Ensure Deno is installed and properly configured. - Permission errors: If your code tries to perform actions not allowed by the selected permissions (e.g., network requests without
Allow Net), it will fail. Adjust permissions accordingly. - Code errors: Runtime errors thrown by the user’s TypeScript code will cause the node to fail unless "continue on fail" is enabled, in which case errors are included in the output JSON.
- Unknown mode or processing values: If the node parameters for Mode or Processing contain unexpected values, the node throws an error indicating the unknown property value.
- Using
.all()method incorrectly: When running code per item, calling$input.all()throws an error because collective access is only available when running once for all items.
Links and References
- Deno Official Website
- Deno Permissions Documentation
- TypeScript Language
- n8n Custom Code Node Documentation (for planned built-in helpers)