Type references in code node

Describe the problem/error/question

Hellooooo community :wave:

I have a self-hosted instance of n8n, and play a lot with code node. To facilitate my workflows, I code a lot of little util functions that I import in my code node, and build higher level logic there.

It works fine, but I’m missing a lot auto-completion in the code node. Luckily, references have been introduce recently helping a lot to suggest functions on the core utils, but it doesn’t seem to work on 3rd party packages that I import.

Example:
If I require lodash this way const _ = require('lodash'), the code editor shows a warning Cannot find module 'lodash' or its corresponding type declarations.

I’m not managing to find a way to declare the types in a way that can be picked by the code node editor… It is possible? Or is it only suggesting the types on the code libs?

Thanks in advance for your help!

Information on your n8n setup

  • n8n version: 1.74.3
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): :thinking:
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Linux

Take a look at this documentation.

And this old topic too.

Does that answer your question? If yes, please remember to mark this reply as the solution.

Hey! Thanks for the links and the suggestions.
I had already looked at those, but it doesn’t really match my request.

Anyway after looking into the code, I saw that we don’t really handle this the way I thoughts. The way we feed the info to the code node editor, to have the autocompletion is far from supporting dynamically gathering all the types from different libs, and offering an autocompletion based on those types.

The effort would be quite significant. Maybe in the future!

I’m closing it for now :+1:

2 Likes