Error "CustomNodes is not a constructor"

Hello everyone,
I’m trying to create a clone of the LmChatOpenAi.node.ts node. The goal is to be able to use the Anyscale service, which utilizes the same endpoints as OpenAI but for open-source models. I started with a custom-node project and did all the configuration to connect my project to my global n8n.

The build works fine, however, when I run n8n start, I get this error:

Error loading node "LmChatAnyscale" from: "/Users/xaviercliquennois/.n8n/custom/node_modules/n8n-custom-nodes/dist/nodes/llms/LMChatAnyscale/LmChatAnyscale.node.js" - require(...).LmChatAnyscale is not a constructor
evalmachine.<anonymous>:1
new (require('/Users/xaviercliquennois/.n8n/custom/node_modules/n8n-custom-nodes/dist/nodes/llms/LMChatAnyscale/LmChatAnyscale.node.js').LmChatAnyscale)()
^

TypeError: require(...).LmChatAnyscale is not a constructor
    at evalmachine.<anonymous>:1:1
    at Script.runInContext (node:vm:134:12)

I don’t see why my node LmChatAnyscale.node.ts, which is a simple clone of LmChatOpenAi.node.ts, doesn’t work.

To get the build to work, I had to add these dependencies:

  1. @n8n/n8n-nodes-langchain”: “^0.18.0”,
  2. “n8n-core”: “1.32.0”,
  3. “n8n-workflow”: “1.32.0”,

You can find my repo here.

Information on your n8n setup

  • n8n version: 1.32.2
  • node version: v18.19.1
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm v8.15.0
  • Operating system: macOS 14.1.2

Thanks for the help.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Xavier-Cliquennois,

The AI nodes are a bit different to the normal nodes and at the moment we don’t an official way to add your own yet but looking at your GitHub project you have not updated the package.json to include your node yet.

You are also using

export class LmAnyscale implements INodeType {

Instead of

export class LmChatAnyscale implements INodeType {