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
npmwhereaspnpmis now the recommended package manager for n8n. - It uses
npm linkto link nodes but making it work withpnpmis 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-nodesfolder. You could also execute the.devcontainer/init.shscript to do it for you. - Create a
.envfile in the.devcontainersfolder. You can use.env.exampleas a template.- Used for docker-compose variable interpolation
- Used as
.envfile for the n8n container
- Use
F1orCtrl+Shift+Pand selectDev Containers: Reopen in Containerin 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 installto install dependencies. - Still inside your custom node folder, run
pnpm buildto build your custom node. - [Optional (done as preLaunchTask inside
launch.json)] You can also runpnpm devin a terminal to watch for changes and rebuild automatically. - Then press
F5to start the n8n server in debug mode usingStart n8nlaunch config. It will runpnpm devin 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 !