Proven workflow on developing code for the Code node

Hi, i’m looking for a stable, proven way to work on the Code node - basically just writing some custom business logic for my workflow.

The first thing that comes to my mind is to save the input from the previous node (data i receive by the API), save it to the variable, set the dev env (e.g. Node.js), develop the logic itself, then copy the code and paste to the Code node. Meanwhile, i can ensure that outpt is more or less reasonable.

Another option may be is to create custom node (inherit the Code node and pre-fill its code with my logic?), but now sure if that is going to increase the development speed.

Any suggestions on it?

After reading this article ( Date and time with Luxon - n8n Documentation ) i thought that the basic node.js projct with Luxon and Jmespath libs should do the job (should i use more libs? probably would dig into n8n src some day).
Plus template starter project with pre-create Input and Output variables, and the Code function itself, which can be
a) tested easily in the VS Code
b) copypasted directly to the Code node

Still, if you have better suggestions - please share.

To be honest, I don’t get the issue.
n8n is a low-code application. The code node is just there so you can easily put in small bits of code to your workflows.
So in my opinion it does not make sense to move this to VS code or similar tools.
Of course you do need to think about your development flow for n8n workflows, but no need to treat the code nodes separately.
If you are doing a lot of development in the code node, you might want to see if n8n is the right tool for your use case.

Might be missing something here, but thats just my 2 cents. :slight_smile:

1 Like

That’s a pretty valid point!

My idea behind that was to outsource js logic development, so the worker can simply set up the env and start working without too much headache learning n8n, entering creds, etc. Just “Hey, here’s input, i need that output, please implement”.

On the other hand, i really like n8n for its flexibility.
I can definitely have API calls in the code - and skip using n8n at all - but, well, then I face all the issues with the common development process.

1 Like

Than you are looking for a basic development flow using git.
You can create something around that to get it into n8n, but all options will be a bit of a hassle.
So better to just copy paste it in when something gets published on a certain git branch for example.

Here’s the project i’ve made to fulfill my request, mentioned in the first message.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.