Node
Runs your own JavaScript code on Node.js inside a process and returns its result, its console output and any error.
The Node action runs a piece of JavaScript code that you write, on Node.js, as one step of your process. Use it for calculations, data clean-up or text processing that no ready-made action covers. The value your code returns becomes an output you can use in the next steps.
Add the action
In the Process Designer toolbox, open Scripting and pick Node (or type Node in the search box).

Inputs and outputs
| Field | Direction | Type | Required | What to put / what you get |
|---|---|---|---|---|
| Code | Input | Text (JavaScript code) | Yes | Your JavaScript code. Use return to send a value back to the process. |
| Timeout | Input | Integer | No | How many seconds the code may run, from 10 to 180. Default 60. |
| Single Result | Output | Any | No | The value your code returns, when it is not an array: a number, text, true/false or an object. |
| List Result | Output | List of any | No | The value your code returns, when it is an array. |
| Stdout | Output | Text | No | Everything your code wrote with console.log(). |
| Error | Output | Text | No | The error message when your code fails or runs too long. Empty when the code worked. |
How your code is run
Your code runs as the body of a function:
return <value>sends the value to Single Result, or to List Result when the value is an array. Only one of the two is filled.console.log()does not set a result; it writes to Stdout.- Code that ends without
returnleaves both results empty. - To wait for something asynchronous, return a promise, for example an
asyncfunction that you call:return (async () => { … })(). - Load a library with
require('name').importstatements are not supported.
Examples
| Code | Output |
|---|---|
var a = 1; var b = 2; return a + b | Single Result 3 |
return 1 == 2 | Single Result false |
console.log('working'); return [1, 'two', {three: 3}] | List Result [1, "two", {"three": 3}], Stdout working |
const _ = require('lodash'); return _.chunk([1,2,3,4], 2) | List Result [[1, 2], [3, 4]] |
throw "Not on my watch" | Error Not on my watch |
var x = 1 then retur x (a typo) | Error Unexpected identifier 'x' |
import _ from 'lodash' | Error 'import' and 'export' may appear only with 'sourceType: module' |
A promise that waits 15 seconds, with Timeout 10 | Error Execution timed out after 10s |
Use process variables in the code
You can insert process variables into the code. Before the code runs, PROCESIO replaces each variable with its value, as plain text. So:
- a number variable can be used as it is:
const total = <your number variable> * 2; - a text variable needs quotes around it in your code:
const name = "<your text variable>".
Good to know
- A failing script does not stop the process. When your code throws, has a syntax error or runs longer than Timeout, the step still finishes: Error holds the message and both results are empty. Add a Decisional after the action that checks whether Error is empty.
- The code runs in a sandbox. Built-in modules that reach the machine, such as
fsorchild_process, are not available, so the script cannot read or write files. - The sandbox can block calls to the internet. To call a web API, use Call API or CURL and pass the response to the script.
- Files: a script cannot take a file directly. Convert the file to text with File To Base64 and pass the text to the script. To create a file from a script, return Base64 text and convert it with Base64 To File.
Available libraries
These libraries can be loaded with require:
| Library | What it is for |
|---|---|
lodash, underscore, ramda | Working with arrays and objects |
moment, date-fns, luxon | Dates and times |
big.js, mathjs, simple-statistics | Precise numbers, maths and statistics |
cheerio, html-to-json-parser, marked | HTML and Markdown |
xml, xml-js | XML |
csv-parse, papaparse | CSV |
validator, joi | Validating values |
uuid, hash.js, qrcode | IDs, hashes, QR codes |
string-similarity | Comparing texts |
@faker-js/faker | Random test data |

