n8n-code-javascript

Guide correct JavaScript logic and data access for n8n Code nodes.

84|23|Updated May 6, 2026
One-click install
npx skills add https://github.com/MorrisLu-Taipei/TigerAI-n8n-Skill-Pack --skill n8n-code-javascript-morrislu-taipei
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/MorrisLu-Taipei/TigerAI-n8n-Skill-Pack/tree/main/skills/_vendor/n8n-code-javascript
Command: npx skills add https://github.com/MorrisLu-Taipei/TigerAI-n8n-Skill-Pack --skill n8n-code-javascript-morrislu-taipei

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents Code node failures and confusion by teaching the correct JavaScript patterns, data access methods, and return formats for n8n’s Code node environment.

Core Features & Use Cases

  • Mode selection guidance: choose between Run Once for All Items vs Run Once for Each Item based on dataset vs per-item logic needs.
  • Data access patterns: use $input.all(), $input.first(), $input.item, and $node references correctly, including the common webhook gotcha under $json.body.
  • Return format correctness: reliably output the required array of items with the json property to keep downstream workflow steps working.
  • Production-ready error prevention: avoid the most frequent Code node mistakes like missing return statements, incorrect wrappers, expression syntax confusion, null/undefined access, and sandbox restrictions.
  • Built-in function usage: correctly apply $helpers.httpRequest(), DateTime (Luxon), $jmespath(), and $getWorkflowStaticData() within the Code node’s constraints.

Quick Start

Ask: “Turn my webhook payload into a normalized list of users in an n8n Code node, using All Items mode, with safe null checks, and return the data as [{json: {...}}].”

Frequently Asked Questions about n8n-code-javascript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I return data correctly from an n8n Code node?

To return data correctly from an n8n Code node, output an array of items where each item contains a json property, such as [{json: {...}}], ensuring downstream workflow steps can process the structured data without failing.

What is the difference between Run Once for All Items and Run Once for Each Item in n8n?

Run Once for All Items processes the entire dataset in a single execution using $input.all(), whereas Run Once for Each Item executes the JavaScript logic individually per item using $input.item for isolated data transformation.

How do I access webhook payload data in an n8n Code node?

You access webhook payload data in an n8n Code node by referencing the $json.body object, which safely contains the incoming webhook payload structure and prevents null or undefined access errors during execution.

Why does my n8n Code node fail with a missing return statement error?

An n8n Code node fails with a missing return statement error when the JavaScript logic does not explicitly output the required array of items, causing the workflow execution to break before reaching downstream steps.

Can I use Luxon DateTime and JMESPath inside an n8n Code node?

Yes, you can use Luxon DateTime and $jmespath() inside an n8n Code node to handle date formatting and JSON data querying, provided you apply them within the sandbox limitations and use correct expression syntax.

What are the limitations of using $helpers.httpRequest() in n8n JavaScript?

The limitations of using $helpers.httpRequest() in n8n JavaScript include sandbox restrictions that constrain external API calls, requiring compatible syntax and safe data access patterns to prevent execution failures within the Code node environment.