n8n · Code node
Code doesn't return an object
Short answer
This n8n Code node error may occur when the node does not return anything or returns an unexpected result. Make sure that the Code node returns the expected data structure. n8n expects an array of objects, each wrapping another object under the json key.
VerifiedLast verified
01Error text
Code doesn't return an object02Likely causes
- The Code node doesn't return anything, or returns an unexpected result.
- The code returns
undefinedinstead of the expected result.
03How to fix it
- Make sure that the Code node returns the expected data structure. n8n expects an array of objects, each wrapping another object under the
jsonkey. - If the code returns
undefined, make sure that the data you reference exists in each execution and has the structure your code expects.
04Official documentation
→Related errors
- Code doesn't return items properlyThis n8n Code node error occurs when the code does not return data in the expected format. Return an array of objects in which each object wraps your data under the json key.
- A 'json' property isn't an objectThis n8n Code node error occurs when the node returns data where the json key does not point to an object. Make sure that the json key references an object in your return data.
- 'import' and 'export' may only appear at the top levelThis n8n Code node error occurs if you use import or export, which the n8n JavaScript sandbox does not support. Change your import statements to use require, for example const express = require("express");.
Test every fix in a non-production environment before you apply it to production. See how entries are verified.
More for n8n work:Open n8n jobsn8n rates and salaries