I need help with building my custom Node
Hello together,
for the first time I tried to build a custom Node. I’m not very familiar with Nodejs/NPM. AI helped a lot
My Goal is, to build a Trigger Node for the HomeAssistant integration, which uses Websockets - as without a trigger, the HomeAssistant Integration is nearly not useable.
While building I sticked to the official tutorial…
That’s my actual status:
- I can build the Node without errors
- I have created a link
- I’ve added the link to the custom nodes Folder
You can find my code here: n8n-nodes-homeassistanttrigger
Without the custom Node, n8n starts without problems. When linking the custom Node, I’m getting the following error:
User settings loaded from: /home/MySpace/.n8n/config
Initializing n8n process
Error loading node "globals" from: "/home/MySpace/.n8n/custom/node_modules/n8n-nodes-homeassistanttrigger/node_modules/engine.io-client/build/cjs/globals.node.js" - require(...).globals is not a constructor
evalmachine.<anonymous>:1
new (require('/home/MySpace/.n8n/custom/node_modules/n8n-nodes-homeassistanttrigger/node_modules/engine.io-client/build/cjs/globals.node.js').globals)()
^
TypeError: require(...).globals is not a constructor
at evalmachine.<anonymous>:1:1
at Script.runInContext (node:vm:134:12)
at loadClassInIsolation (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/ClassLoader.ts:9:16)
at CustomDirectoryLoader.loadNodeFromFile (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:91:35)
at CustomDirectoryLoader.loadAll (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:335:9)
at LoadNodesAndCredentials.runDirectoryLoader (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:270:3)
at LoadNodesAndCredentials.loadNodesFromCustomDirectories (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:181:4)
at LoadNodesAndCredentials.init (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:100:3)
at Start.init (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts:72:3)
at Start.init (/usr/local/lib/node_modules/n8n/src/commands/start.ts:192:3)
Exiting due to an error.
Error: Exiting due to an error.
at Start.exitWithCrash (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts:151:23)
at Start.catch (/usr/local/lib/node_modules/n8n/src/commands/start.ts:363:14)
at Start._run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/core/lib/command.js:306:29)
at Config.runCommand (/usr/local/lib/node_modules/n8n/node_modules/@oclif/core/lib/config/config.js:424:25)
at run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/core/lib/main.js:94:16)
at /usr/local/lib/node_modules/n8n/bin/n8n:71:2
require(...).globals is not a constructor
evalmachine.<anonymous>:1
new (require('/home/MySpace/.n8n/custom/node_modules/n8n-nodes-homeassistanttrigger/node_modules/engine.io-client/build/cjs/globals.node.js').globals)()
^
TypeError: require(...).globals is not a constructor
at evalmachine.<anonymous>:1:1
at Script.runInContext (node:vm:134:12)
at loadClassInIsolation (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/ClassLoader.ts:9:16)
at CustomDirectoryLoader.loadNodeFromFile (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:91:35)
at CustomDirectoryLoader.loadAll (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:335:9)
at LoadNodesAndCredentials.runDirectoryLoader (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:270:3)
at LoadNodesAndCredentials.loadNodesFromCustomDirectories (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:181:4)
at LoadNodesAndCredentials.init (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:100:3)
at Start.init (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts:72:3)
at Start.init (/usr/local/lib/node_modules/n8n/src/commands/start.ts:192:3)
I think, It has something to do with teh websocket lib, which I use. I’ve looked into other Nodes, which use websockets and copied from there.
Please help me!
Information on your n8n setup
- n8n version: npm 9.2.0
- Database (default: SQLite): default
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): npm
- Operating system: ubuntu 24.04.1