Skip to content
MoveWorkflows

Pipedream code steps → n8n Code node

Updated 2026-10-21 · 5 min read

Check a code step for the n8n Code node
Runs in your browser. The code is not sent anywhere.
In short
  • A Pipedream step is a run({ steps, $ }) component; an n8n Code node returns items.
  • On n8n Cloud the Code node can load only crypto and moment; self-hosted can allow more.
  • In n8n 2.x the Code node has no fetch, URL or process. Test every converted step.
On this page · 8 sections
  1. What to do now
  2. The two models
  3. Mapping table
  4. All items or each item?
  5. HTTP calls and npm
  6. Rewrite or wrap?
  7. Limits worth checking
  8. Next steps

Most Pipedream code steps end up in the n8n Code node. Both run JavaScript, but the code has a different shape. A Pipedream step is a component with a run({ steps, $ }) method. The n8n Code node receives items and must return items. This page maps every Pipedream code-step concept to its n8n equivalent, with before-and-after code.

What to do now

  1. Run the free report on your export. It lists the npm imports in your code steps. Check my export
  2. Check your npm imports first. On n8n Cloud the Code node loads only crypto and moment. Other packages need self-hosted n8n or a rewrite.
  3. Choose per step: rewrite or wrap. Rewrite short steps you will keep. Wrapping is faster when you have many steps, and the tested logic stays as it is.
  4. Test every converted step after import. Run it with realistic data before you switch traffic.

The two models

Here is a Pipedream Node.js code step. It runs on Node.js v20.

export default defineComponent({
  async run({ steps, $ }) {
    const body = steps.trigger.event.body;
    if (!body.email) return $.flow.exit("no email");
    $.export("domain", body.email.split("@")[1]);
    return { email: body.email.toLowerCase() };
  },
});

Here is the same logic in an n8n Code node, in the mode "Run Once for All Items":

const body = $('Webhook').first().json.body;
if (!body.email) return [];
return [{ json: {
  email: body.email.toLowerCase(),
  domain: body.email.split('@')[1],
} }];

Three differences matter:

  1. No component wrapper. The Code node body is the function itself.
  2. Data is items. n8n passes an array of items between nodes. Each item looks like { json: {...} } (data structure docs). If you return plain objects, n8n adds the json key for you.
  3. Stopping means returning nothing. If you return an empty array, the next nodes get no items and don't run.

Mapping table

Pipedream n8n Code node
defineComponent({ async run({ steps, $ }) {...} }) The Code node body (async is allowed)
steps.trigger.event $('Webhook').first().json (use the name of your trigger node)
steps.my_step.$return_value $('my_step').first().json
steps.my_step.foo (from $.export("foo", …)) $('my_step').first().json.foo
return value return [{ json: value }]
$.export(name, value) Add name as a field of the returned item
return $.flow.exit("reason") return [], or an If node before the step
$.respond({ status, body }) A Respond to Webhook node after the Code node
$.flow.delay(ms) A Wait node between two Code nodes
$.flow.rerun(...) No equivalent. Use a Wait node and a loop, or Retry On Fail
process.env.KEY $vars.KEY (Cloud Pro/Enterprise, self-hosted Business/Enterprise). Code nodes can't read credentials, so API keys belong on the node that makes the call
this.slack.$auth.oauth_access_token An n8n credential on an HTTP Request node or app node
import axios from "axios" An HTTP Request node
Any npm import Only require(), because the Code node doesn't accept ES import. Cloud: crypto and moment. Self-hosted: allow-listed packages
console.log The browser console of the n8n editor

n8n documents the node reference syntax ($('Node name'), $input.first(), $input.all()) on its reference previous nodes page. In the Code node, $json works only in the mode "Run Once for Each Item".

All items or each item?

The Code node has two modes:

  • Run Once for All Items (the default). Your code runs once and gets every item through $input.all(). This is closest to a Pipedream step, which runs once per event.
  • Run Once for Each Item. Your code runs once per item and uses $json / $input.item. Use it after a node that returns a list, where Pipedream would have needed a loop.

If a Pipedream trigger delivered one event, there is one item. Then both modes behave the same.

HTTP calls and npm

Pipedream code steps often call APIs with axios or the @pipedream/platform wrapper. In n8n, the cleanest replacement is an HTTP Request node before or after the Code node. It handles credentials, pagination and retries. n8n's Code node docs say the Code node can't make HTTP requests and send you to that node.

npm is the other big change. On n8n Cloud the Code node can load only crypto and moment. On self-hosted n8n you install packages in the task runner image and allow-list them. The task runner is the separate process n8n uses to run Code node code. Full setup: npm packages in n8n.

Rewrite or wrap?

You can move a code step in two ways:

  • Rewrite it in the n8n style shown above. This is best for short steps and for code you'll keep maintaining.
  • Wrap the original component in a compatibility layer. The layer provides steps and $ inside the Code node. This is faster for many steps, and the logic stays as it was tested in Pipedream.

Our converter wraps. Each code step becomes a Code node that calls the original run(). The converter emulates steps, $.export, $.flow.exit and $.respond. It keeps step names, so references stay valid.

The n8n 2.x Code node sandbox has no fetch, URL, URLSearchParams, AbortController or process. Built-in modules such as fs are blocked unless allow-listed. Our converter inserts fetch and axios shims built on this.helpers.httpRequest. n8n doesn't document this helper for the Code node, so test every converted code step after import. The report lists npm imports, so you know which steps need self-hosted n8n or a rewrite. To check a single step for free, use the Code node compatibility check.

Limits worth checking

Pipedream code steps ran with 256 MB of memory by default. On paid plans they could run up to 750 seconds (limits). On n8n Cloud the maximum execution duration depends on the plan. On self-hosted n8n it depends on your server. Long-running steps deserve a test run with realistic data before you switch traffic. Examples are large file processing and slow APIs.

Next steps

Not affiliated with Pipedream or n8n.

FAQ

Does the n8n Code node support JavaScript and Python?

Yes. The Code node runs JavaScript or Python. Python runs natively through task runners in n8n 2.x.

What is the n8n equivalent of steps.trigger.event?

Read the trigger node's output with $('Webhook').first().json, or $input.first().json if the trigger is the previous node.

What replaces $.export in n8n?

Return the values as fields of the item: return [{ json: { total: 42 } }]. The next nodes read them as $json.total or $('Node name').first().json.total.

Can the n8n Code node make HTTP requests?

n8n's Code node docs say it can't make HTTP requests. They point you to the HTTP Request node. Move API calls there where you can.

Can I use npm packages in the n8n Code node?

On n8n Cloud only crypto and moment. On self-hosted n8n you install packages in the task runner image and allow-list them.