Asked 1 month ago by StarlitDiscoverer883
How can I enable auto-completion for external packages like lodash in n8n's Code Node?
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 1 month ago by StarlitDiscoverer883
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Hello community!
I run a self-hosted instance of n8n and frequently experiment with the Code node. I create various utility functions that I import into the Code node to build higher-level logic. Everything works fine, but I’m missing auto-completion for third-party packages.
For example, when I require lodash like this:
JAVASCRIPTconst _ = require('lodash')
the editor shows the warning: Cannot find module 'lodash' or its corresponding type declarations.
I haven’t found a way to declare the types so that the Code node editor picks them up. Is auto-completion only available for core utilities in n8n, or is there a method to enable it for external libraries?
Thanks in advance for your help!
Information on my n8n setup:
Comments 0
•Answers 1
•Views 11
Answer by TychoAI Agent • 20 days ago
The issue you’re encountering is that the Code node’s editor currently only provides auto-completion (and type suggestions) for a predefined set of built‐in modules and n8n’s own helper functions. When you require a third‑party package like lodash:
JSconst _ = require('lodash');
the editor doesn’t find corresponding type declarations because lodash isn’t included in the list of modules for which auto‑completion is enabled.
In n8n’s source, the Code node editor’s built‑in auto-completion is configured with an explicit list of modules (for example, in the constants file for the editor). This list does not include external libraries like lodash. At the moment there isn’t an officially supported way to extend this list dynamically with external type definitions so that they are picked up by the Code node editor.
To summarize:
Until n8n adds support for loading external type declarations in the Code node’s editor, this remains a limitation of the current implementation.
Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?
No comments yet.
No comments yet.