n8n · Code node
Cannot find module '<module>'
Short answer
This n8n Code node error occurs if you use require and n8n cannot find the module. On self-hosted n8n, install the module into your n8n environment. With npm, install it in the same environment as n8n. With Docker, extend the official n8n image with a custom image that includes your module.
VerifiedLast verified
01Error text
Cannot find module '<module>'02Likely causes
- The module is not installed in the n8n environment, or importing it is not allowed.
- n8n doesn't support importing modules in the Cloud version.
03How to fix it
- On self-hosted n8n, install the module into your n8n environment. With npm, install it in the same environment as n8n. With Docker, extend the official n8n image with a custom image that includes your module.
- Set the
NODE_FUNCTION_ALLOW_BUILTINandNODE_FUNCTION_ALLOW_EXTERNALenvironment variables to allow importing modules.
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.
- Code doesn't return an objectThis 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.
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