Skip to main content
Skip table of contents

How to use external modules in a function node


The function node allows you to write code in JavaScript and also to make use of libraries and modules shared on npm. This guide explains the basic steps of setting up a function node with an external module.

  1. Double click on your function node to open the Properties panel.

  2. Defining the modules

    1. Navigate to the Setup tab of the function node. Here you can find the Modules section.

    2. Click on the +add button to define a new module you want to install and use.

    3. Enter the module name, for example: @aws-sdk/client-s3. This must match the exact name of the corresponding npm module hosted on .

    4. In the Import as field, define a new variable name, for example: AwsSdkClientS3. You will need to use the variable name in your code to import the module.

  3. Using the modules in your code

    1. Navigate to the On Message tab of the function node.

    2. Import the module into your code by making use of the previously defined “Import as” variable name:

    3. JS
      // import module
      const { S3Client, ListObjectsV2Command } = AwsSdkClientS3;
      // use imported module
      const client = new S3Client({credentials: {accessKeyId: msg.s3.accessKey,secretAccessKey: msg.s3.secretKey}, region: msg.s3.region});
  4. Click Done to close the panel.

  5. Click Save to save the flow.

Installation process of external modules

The flow app will now detect that a new module was defined. If that module wasn’t already installed on the app, it will be automatically installed. During this process, you won’t be able to trigger the flow (e.g. manual triggers of inject nodes will be temporarily disabled).

Depending of the size and dependencies of the module, the installation usually takes one or multiple minutes. You can track the progress of the installation process in the Event Log.

To lookup the progress of the installation process, do the following steps:

  1. Click on the menu icon in the top-right of the screen of the Flow Editor.

  2. Click on View>Events to open the Event Log panel.

This is how a typical output of a module install process looks like:

2023-03-20T07:25:04.768Z npm install --production --engine-strict @aws-sdk/client-s3
2023-03-20T07:25:06.031Z [out] (Use `node --trace-warnings ...` to show where the warning was created)
2023-03-20T07:25:42.185Z [out] added 228 packages, changed 1 package, and audited 304 packages in 37s
2023-03-20T07:25:42.250Z rc=0

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.