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
whereaspnpm
is now the recommended package manager for n8n. - It uses
npm link
to link nodes but making it work withpnpm
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.
.
├── .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
- Clone this repository and navigate to the root folder.
- [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. - Create a
.env
file in the.devcontainers
folder. You can use.env.example
as a template.- Used for docker-compose variable interpolation
- Used as
.env
file for the n8n container
- Use
F1
orCtrl+Shift+P
and selectDev 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. - Go to your custom node folder and run
pnpm install
to install dependencies. - Still inside your custom node folder, run
pnpm build
to build your custom node. - [Optional (done as preLaunchTask inside
launch.json
)] You can also runpnpm dev
in a terminal to watch for changes and rebuild automatically. - Then press
F5
to start the n8n server in debug mode usingStart n8n
launch config. It will runpnpm dev
in the custom nodes folder and start the n8n server in debug mode. - Add breakpoint to your custom node Typescript or n8n source code and start debugging !