Skip to main content

JavaScript Executor

Our Run JavaScript Code module allows you to run Python code on the Bun runtime, inside a relatively standard Linux environment. Bun is almost completely compatible with Node.js, you can assume that it works the same. You can find the API docs here.

Overview

JavaScript Module in Make

You can currently configure only the code here. The code must be valid JavaScript (not TypeScript) code, and will run on the Bun runtime. You can use any npm package you want, it will be installed automatically.

warning

Printing something to the console has absolutely no effect. Make sure that you return values either by assigning to the global result variable (which must not be redeclared), or by using a top-level return statement.

warning

Do not use import to import packages, that will cause a syntax error. Instead, use require.

tip

You can use top-level await if you are performing anything asynchronous.

Pricing

The JavaScript executor costs 50 credits per execution (of up to 3 minutes).

Examples

This section presents a couple of very basic JavaScript examples. They are mostly there to show how to return data from the code executor. If you want to learn JavaScript (Node.js) itself, take a look here.

multiply_numbers.js
function multiplyNumbers(number1, number2) {
return number1 * number2;
}
// assign to top-level result variable
result = {
data: multiplyNumbers(54, 67);
};
fetch_example.js
// top-level await
const response = await fetch("https://www.0codekit.com");
// top-level return
return {
data: await response.text(),
};
require_example.js
// just require any npm package you like
const _ = require("lodash");
return {
data: _.partition([1, 2, 3, 4], (n) => n % 2),
};