Skip to content

mathisgauthey/n8n-nodes-builder

Repository files navigation

n8n-nodes-builder

Introduction

This repository aims to provide a simple way to get into developing nodes for n8n.

I am making it because the documentation on building custom nodes is currently outdated, and left many wondering how to get started.

It is outdated because :

  • It uses npm whereas pnpm is now the recommended package manager for n8n.
  • It uses npm link to link nodes but making it work with pnpm is undocumented and people seems to rather use docker to make it work flawlessly.

Let's add that n8n itself is using devcontainers to help maintainers make contributions easier, so why not use it to develop custom nodes as well?

And this is exactly what this repository is all about.

Overview

.
├── .devcontainers/
│   ├── .env.example                        # Environment variables template file
│   ├── Dockerfile                          # Dev container Dockerfile
│   ├── devcontainer.json                   # Dev container configuration
│   ├── docker-compose.devcontainer.yaml    # Devcontainer specific docker-compose
│   ├── docker-compose.yaml                 # Main docker-compose configuration
│   ├── init.sh                             # Init script to clone repos
│   └── link_custom_nodes.sh                # Script to link custom nodes to n8n 
├── .vscode/
│   └── launch.json                         # VSCode launch configuration
├── custom-nodes/
│   ├── custom-node-1/
│   │   ├── dist/                           # Custom node 1 build folder
│   │   └── ...
│   └── custom-node-2/
│       ├── dist/                           # Custom node 2 build folder
│       └── ...
├── n8n/                                    # n8n source code             
│   └── ...
├── .gitignore
├── LICENSE
└── README.md

How to use

  1. Clone this repository and navigate to the root folder.
  2. [Optional (done during the dev container creation process)] Clone the n8n repository at the workspace root and the n8n-nodes-starter repository in the custom-nodes folder. You could also execute the .devcontainer/init.sh script to do it for you.
  3. Create a .env file in the .devcontainers folder. You can use .env.example as a template.
  4. Use F1 or Ctrl+Shift+P and select Dev Containers: Reopen in Container in VSCode. The first start it long (5m on my end) because it builds up n8n from source, but subsequent starts are a matter of seconds.
  5. Go to your custom node folder and run pnpm install to install dependencies.
  6. Still inside your custom node folder, run pnpm build to build your custom node.
  7. [Optional (done as preLaunchTask inside launch.json)] You can also run pnpm dev in a terminal to watch for changes and rebuild automatically.
  8. Then press F5 to start the n8n server in debug mode using Start n8n launch config. It will run pnpm dev in the custom nodes folder and start the n8n server in debug mode.
  9. Add breakpoint to your custom node Typescript or n8n source code and start debugging !

Inspirations

About

Quick and easy way to get into n8n nodes development.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •