Building a custom node

I’m looking to build a custom node and integrate OAuth and eventually submit a PR to the main repo. I’ve been digging around the project and can’t figure out how to add a new node locally, I’ve created a node and imported the node to the /nodes-base/package.json file but whenever I run the API endpoints in /cli/Server.ts, the node doesn’t appear under the /node-types endpoint.

How can I get n8n to work with a custom module I build locally?

Did you see this guide already? If not I think it should explain everything you have to do:

Yes, I saw it. Thank you. I have followed the guide and created the node but it still does not appear? Any idea as to why this might happen? I’m running with npm run build from within /cli. Thank you.

Did you follow the full guide without taking any shortcuts? Because it, for example, mentions starting with npm run dev from the root folder. If you do only run npm run build in “/cli” it will never compile the TypeScript code to JavaScript and the node will so not be found on startup.

Hi Jan, I see the node in the /nodes-base/dist/credentials folder as a .js file. See attached screenshot. Is this correct? I’m still not getting the node to appear in the /node-types endpoint though…

Ah yes, that are two different things. There are credentials and there are the actual nodes (which contain all the logic and which use the credentials).
The credentials get returned from the credentials endpoint (/rest/credentials) and the nodes from the node-types one (/rest/node-types).

Understood. I created a custom credential and a custom node - both appear under the /nodes-base/dist/ folder (under /nodes-base/dist/nodes and /nodes-base/dist/ credentials, respectively). But in /rest/credentials and /rest/node-types and /rest/credential-types the custom nodes and credentials still don’t show…

Thoughts?

The only explanation I would have is still that one or multiple steps got skipped from the guide. Like for example the lerna-setup. Because then it would not link the module, it would use the npm installed one instead which would obviously not have your code and would so not show up.

I can’t get lerna to run without errors. See attached logs. I’m running from root, any thoughts?

[email protected] uninstall /Users/tjenkins/Desktop/n8n/node_modules/yorkie
node bin/uninstall.js

internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module ‘/Users/tjenkins/Desktop/n8n/node_modules/yorkie/bin/uninstall.js’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm WARN lifecycle [email protected]~uninstall: continuing anyway [email protected] uninstall: node bin/uninstall.js
npm WARN lifecycle Exit status 1
npm ERR! Maximum call stack size exceeded

Sorry, not the slightest idea. Are you running it directly on your host or inside of Docker? If Docker, what kind of image are you using? An Alpine one? If so maybe try with an Ubuntu based one.

As the issue is not directly related to n8n there is sadly not much I can help you with.