While loading custom node, n8n tries to find others in dependences

Describe the problem/error/question

I’m working on a custom n8n node to support Sentence TransformerEmbeddings without a Hugging Face Api Key. To do so, I import the dependence @xenova/transformers needed by @langchain/community/embeddings/hf_transformers
When I try to start n8n, I have the following error. It looks like n8n is trying to load all files named *.node.js as custom node even those located in the node_modules folder of my custom node.
Is that true ? Is there a way to prevent it from doing so ?
My code is available here : GitHub - Kurea/n8n-nodes-neo4j: N8N node to work with your data in Neo4j Vector Store
Note : the node VectorStoreNeo4j and it’s credentials are working fine, I juste added the nodes/embeddings/EmbeddingsHuggingFaceTransformers/ directory, the node data in package.json and the dependency.
Thanks for your help !

What is the error message (if any)?

2024-06-21T20:18:35.145Z | info | Initializing n8n process “{ file: ‘start.js’, function: ‘init’ }”
2024-06-21T20:18:35.186Z | debug | Lazy Loading credentials and nodes from n8n-nodes-base “{\n credentials: 356,\n nodes: 453,\n file: ‘LoggerProxy.js’,\n function: ‘exports.debug’\n}”
2024-06-21T20:18:35.189Z | debug | Lazy Loading credentials and nodes from @n8n/n8n-nodes-langchain “{\n credentials: 15,\n nodes: 73,\n file: ‘LoggerProxy.js’,\n function: ‘exports.debug’\n}”
2024-06-21T20:18:35.246Z | error | Error loading node “ort-common” from: “/Users/claire/.n8n/custom/node_modules/n8n-nodes-neo4j/node_modules/onnxruntime-common/dist/ort-common.node.js” - common is not defined “{ file: ‘LoggerProxy.js’, function: ‘exports.error’ }”
2024-06-21T20:18:35.246Z | error | evalmachine.:1
new (require(‘/Users/claire/.n8n/custom/node_modules/n8n-nodes-neo4j/node_modules/onnxruntime-common/dist/ort-common.node.js’).ort-common)()
^

ReferenceError: common is not defined
at evalmachine.:1:132
at Script.runInContext (node:vm:148:12)
at loadClassInIsolation (/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-core/src/ClassLoader.ts:9:16)
at CustomDirectoryLoader.loadNodeFromFile (/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:83:35)
at CustomDirectoryLoader.loadAll (/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:312:9)
at LoadNodesAndCredentials.runDirectoryLoader (/opt/homebrew/lib/node_modules/n8n/src/LoadNodesAndCredentials.ts:257:3)
at LoadNodesAndCredentials.loadNodesFromCustomDirectories (/opt/homebrew/lib/node_modules/n8n/src/LoadNodesAndCredentials.ts:175:4)
at LoadNodesAndCredentials.init (/opt/homebrew/lib/node_modules/n8n/src/LoadNodesAndCredentials.ts:94:3)
at Start.init (/opt/homebrew/lib/node_modules/n8n/src/commands/BaseCommand.ts:62:3)
at Start.init (/opt/homebrew/lib/node_modules/n8n/src/commands/start.ts:174:3) “{ file: ‘start.js’, function: ‘catch’ }”
2024-06-21T20:18:35.246Z | error | Error: Exiting due to an error. “{ file: ‘LoggerProxy.js’, function: ‘exports.error’ }”
2024-06-21T20:18:35.246Z | error | ReferenceError: common is not defined “{ file: ‘LoggerProxy.js’, function: ‘exports.error’ }”

Information on your n8n setup

  • **n8n version:**1.45.1
  • **Database (default: SQLite):**default
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**installed as global through npm - run as n8n start
  • **Operating system:**Mac OS 14.5 Sonoma

Adding a link to the latest version containing embeddings as I need to update the repo : GitHub - Kurea/n8n-nodes-neo4j at c386e04200339c7e6ca39692ad17d7eebef138f1

Hey @Claire,

You might need to update your dependencies as you shouldn’t be importing n8n which can cause issues. It may also be worth trying an update and seeing if that helps.

Hi @Jon,
Thanks for your answer.
What do you mean ? I don’t think I’m importing n8n as a dependency. I have n8n-workflow as a peerDependendcy (which I think is mandatory, isn’t it ?)

Hey @Claire,

Looking at the repo you have n8n under dependencies as well so could be worth dropping that and seeing how it goes.

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