Issues creating custom nodes

Describe the problem/error/question

It’s close to impossible to create custom nodes.
As described here, the official documentaiton is wrong: https://www.youtube.com/watch?v=nX_8OVhUVSY&ab_channel=BenYoungAI

Additionnally, it seems impossible to fully install n8n with pnpm, as pnpm n8n gives me:
Initializing n8n process
There was an error initializing DB
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save

I have tried to install n8n with npm using:
npm cache clean --force
pnpm store prune
rm -rf ~/.n8n

pnpm install n8n -g

What is the error message (if any)?

Initializing n8n process
There was an error initializing DB
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save

Information on your n8n setup

  • n8n version: n8n 1.79.3
  • Database (default: SQLite): sqlite3
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Pnpm
  • Operating system: Ubuntu in WSL2

It sounds frustrating to run into issues when trying to create custom nodes and install n8n! Let’s try to sort this out.

Regarding the custom nodes, the official documentation aims to guide you through the process, but it’s possible that some parts might be unclear or outdated. Could you specify which parts of the documentation (2) you are finding difficult to follow or believe are incorrect based on the YouTube video you mentioned? Knowing the specific points of confusion will help in addressing them and improving the documentation.

There are two main styles for creating nodes: declarative and programmatic. Are you trying to build a node using the declarative style (3) or the programmatic style (4)? Perhaps knowing which style you are attempting will help narrow down the issue.

As for the sqlite3 error when installing n8n with pnpm, the error message β€œSQLite package has not been found installed. Try to install it: npm install sqlite3 --save” is indeed suggesting you use npm to install sqlite3.

While n8n itself can be installed and run using pnpm, it seems that for certain dependencies, especially those related to the database, npm might be expected or better supported.

Could you try installing sqlite3 using npm as suggested by the error message, even if you are using pnpm for n8n itself? You can try running:

npm install sqlite3 --save

in your terminal after you encounter the error.

Alternatively, for a smoother installation experience, especially if you are new to n8n, you might want to try installing n8n globally using npm instead of pnpm. The official documentation primarily uses npm for installation instructions. You can install n8n with npm using:

npm install n8n -g

(5)

If you still encounter issues after trying these steps, please provide more details about:

  • Specific steps you are following from the documentation for custom nodes.
  • Where exactly you are getting stuck or what seems incorrect.
  • Whether you tried installing sqlite3 with npm.
  • If you are intentionally using pnpm for a specific reason, or if you are open to using npm for installation.

The more information you can provide, the better I can assist you in resolving these issues!

Hi @Daniel_Lamphere, thank you so much for the quick answer.
The part that is wrong in the official documentation is simply 1. npm link that simply does not work, as mentionned in https://www.youtube.com/watch?v=nX_8OVhUVSY&ab_channel=BenYoungAI

I get an UNSUPPORTED PROTOCOL, which hints at a conflict between npm & pnpm, because probably pnpm is the mandatory package manager in the package.json file, as per the master branch commits history.

I did try to completely remove n8n and resinstall it, both with npm & pnpm
Trying to install sqlite3 with pnpm does not work: What did work was to:

  1. Remove everhthing and reinstall n8n with npm
  2. pnpm link (not npm) in ~/DEV/n8n-nodes-nasapics/nodes/NasaPics
  3. In ~/.n8n/custom:
pnpm init
pnpm link NasaPics

Following which, I do see the custom node_modules

~/.n8n/custom$ ls node_modules/
.pnpm/ .pnpm-workspace-state.json NasaPics/

But there is still nothing appearing in the UI when looking for β€œPics”

Thanks again @Daniel_Lamphere

  1. Restart does not work
  2. I’ve started n8n in the terminal (n8n start, with n8n being in ~/.nvm/versions/node/v22.4.0/bin/n8n). No log is shown in the console
  3. NasaPics.node.ts is the following:
import { INodeType, INodeTypeDescription } from 'n8n-workflow';

export class NasaPics implements INodeType {
	description: INodeTypeDescription = {
		// Basic node details will go here
		displayName: 'NASA Pics',
		name: 'NasaPics',
		icon: 'file:10865551.svg',
		group: ['transform'],
		version: 1,
		subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
		description: 'Get data from NASAs API',
		defaults: {
			name: 'NASA Pics',
		},
		inputs: ['main'],
		outputs: ['main'],
		credentials: [
			{
				name: 'NasaPicsApi',
				required: true,
			},
		],
		requestDefaults: {
			baseURL: 'https://api.nasa.gov',
			headers: {
				Accept: 'application/json',
				'Content-Type': 'application/json',
			},
		},
		properties: [
			{
				displayName: 'Resource',
				name: 'resource',
				type: 'options',
				noDataExpression: true,
				options: [
					{
						name: 'Astronomy Picture of the Day',
						value: 'astronomyPictureOfTheDay',
					},
					{
						name: 'Mars Rover Photos',
						value: 'marsRoverPhotos',
					},
				],
				default: 'astronomyPictureOfTheDay',
			},
			// Operations will go here
			{
				displayName: 'Operation',
				name: 'operation',
				type: 'options',
				noDataExpression: true,
				displayOptions: {
					show: {
						resource: [
							'astronomyPictureOfTheDay',
						],
					},
				},
				options: [
					{
						name: 'Get',
						value: 'get',
						action: 'Get the APOD',
						description: 'Get the Astronomy Picture of the day',
						routing: {
							request: {
								method: 'GET',
								url: '/planetary/apod',
							},
						},
					},
				],
				default: 'get',
			},
			{
				displayName: 'Operation',
				name: 'operation',
				type: 'options',
				noDataExpression: true,
				displayOptions: {
					show: {
						resource: [
							'marsRoverPhotos',
						],
					},
				},
				options: [
					{
						name: 'Get',
						value: 'get',
						action: 'Get Mars Rover photos',
						description: 'Get photos from the Mars Rover',
						routing: {
							request: {
								method: 'GET',
							},
						},
					},
				],
				default: 'get',
			},
			{
				displayName: 'Rover name',
				description: 'Choose which Mars Rover to get a photo from',
				required: true,
				name: 'roverName',
				type: 'options',
				options: [
					{name: 'Curiosity', value: 'curiosity'},
					{name: 'Opportunity', value: 'opportunity'},
					{name: 'Perseverance', value: 'perseverance'},
					{name: 'Spirit', value: 'spirit'},
				],
				routing: {
					request: {
						url: '=/mars-photos/api/v1/rovers/{{$value}}/photos',
					},
				},
				default: 'curiosity',
				displayOptions: {
					show: {
						resource: [
							'marsRoverPhotos',
						],
					},
				},
			},
			{
				displayName: 'Date',
				description: 'Earth date',
				required: true,
				name: 'marsRoverDate',
				type: 'dateTime',
				default:'',
				displayOptions: {
					show: {
						resource: [
							'marsRoverPhotos',
						],
					},
				},
				routing: {
					request: {
						// You've already set up the URL. qs appends the value of the field as a query string
						qs: {
							earth_date: '={{ new Date($value).toISOString().substr(0,10) }}',
						},
					},
				},
			},
			// Optional/additional fields will go here
			{
				displayName: 'Additional Fields',
				name: 'additionalFields',
				type: 'collection',
				default: {},
				placeholder: 'Add Field',
				displayOptions: {
					show: {
						resource: [
							'astronomyPictureOfTheDay',
						],
						operation: [
							'get',
						],
					},
				},
				options: [
					{
						displayName: 'Date',
						name: 'apodDate',
						type: 'dateTime',
						default: '',
						routing: {
							request: {
								// You've already set up the URL. qs appends the value of the field as a query string
								qs: {
									date: '={{ new Date($value).toISOString().substr(0,10) }}',
								},
							},
						},
					},
				],
			}

		]
	};
}
  1. $ ls -alR ~/.n8n/custom/node_modules/NasaPics
    lrwxrwxrwx 1 charlou charlou 57 Feb 24 11:38 $HOME/.n8n/custom/node_modules/NasaPics β†’ …/…/…/.local/share/pnpm/global/5/node_modules/NasaPics

Hi @Daniel_Lamphere it doesn’t help, unfortunately.
Additional troubleshooting: My custom node is the simplest ever (and directly written from the tutorial). Furthermore, npm init is run in the .n8n/custom directory, not in the .n8n one

  1. My package.json includes paragraphs you seem to have missed, namely:
  "devDependencies": {
    "@typescript-eslint/parser": "^7.15.0",
    "eslint": "^8.56.0",
    "eslint-plugin-n8n-nodes-base": "^1.16.1",
    "gulp": "^4.0.2",
    "prettier": "^3.3.2",
    "typescript": "^5.5.3"
  },
  "peerDependencies": {
    "n8n-workflow": "*"
  },
  "dependencies": {
    "NasaPics": "link:/home/charlou/DEV/n8n-nodes-nasapics/nodes/NasaPics"
  }

When running npm link inside DEV/n8n-nodes-nasapics, I get the following error:

~/DEV/n8n-nodes-nasapics$ npm link
npm error code 1
npm error path /home/charlou/DEV/n8n-nodes-nasapics
npm error command failed
npm error command sh -c npx only-allow pnpm
npm error ╔═════════════════════════════════════════════════════════════╗
npm error β•‘                                                             β•‘
npm error β•‘   Use "pnpm install" for installation in this project.      β•‘
npm error β•‘                                                             β•‘
npm error β•‘   If you don't have pnpm, install it via "npm i -g pnpm".   β•‘
npm error β•‘   For more details, go to https://pnpm.js.org/              β•‘
npm error β•‘                                                             β•‘
npm error β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
npm error npm warn exec The following package was not found and will be installed: [email protected]
npm error A complete log of this run can be found in: /home/charlou/.npm/_logs/2025-03-04T05_46_30_301Z-debug-0.log

Inside detailed logs, I get:

19 info run [email protected] preinstall ../../../../../DEV/n8n-nodes-nasapics npx only-allow pnpm

Which clearly shows the incompatibility between package.json as on the master branch of n8n, and the command (npm link) to be run

That simply does not work

@Daniel_Lamphere FYI I’ve also tried the following after solving another β€œnpm error code EUNSUPPORTEDPROTOCOL” error:

  1. Checking the exact location where my n8n-nodes-nasapics is stored
  2. Linking it manually in ~/.n8n/custom
$ ln -s /my/home/.nvm/versions/node/v22.4.0/lib/node_modules/n8n-nodes-nasapics n8n-nodes-nasapics

~/.n8n/custom$ ls -alht
total 16K
lrwxrwxrwx 1 charlou charlou   76 Mar  6 12:02 n8n-nodes-nasapics -> /my/home/.nvm/versions/node/v22.4.0/lib/node_modules/n8n-nodes-nasapics

After a n8n start, it still does not work

Based on what I gathered around here, I found out that many people including me are struggling with custom nodes.

I created a github repo to help out with it, allowing you to create your custom nodes and see them on the local n8n instance in a matter of a few clicks using VS Code devcontainers.

You can’t yet debug custom node using VS Code directly on the Typescript but I’m working on it. Feel free to land me a hand if you happen to know how Typescript building is working.

Edit : Debugging is now working, I just struggle with hot reload. Step by step I suppose :man_dancing:

@Gentleman9914 Thank you so much for your work
I’m trying it, devcontainers are new to me and I encounter some errors, but I’ll let you know in issues directly on your repo

Thanks again

1 Like

Just wanted to chime in here and echo all the things that OP mentioned. At some point, the developers decided to change from using npm to pnpm but neglected to update the documentation.

Additionally, I’ve been getting linting errors because the underlying implementation of declaring nodes has changed, but the linter rules haven’t been updated either. I’m currently stuck in an infinite loop with the values for inputs and outputs being either ['main'] or [NodeConnectionType.Main], both of which are currently failing the linter.

These issues have been documented in the respective repos, but so far, no action has been taken. The net result is that trying to create a custom n8n node is currently impossible.

1 Like

Thanks for wrapping things up!

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