How to use Supabase in custom langchain code node

I am currently running the ai beta through, using a dockerfile in a github repo.

Langchain runs great!

So now I want to use a custom langchain code node to retrieve relevant documents with relevancy score.

   * Search for the most similar documents to a query,
   * and return their similarity score
    query: string,
    k = 4,
    filter: object | undefined = undefined
  ): Promise<[object, number][]>;

source: Vector stores | 🦜️🔗 Langchain

Not sure yet how to do this, but anyway when I try to use supabase in the custom code node, I get this error:

ERROR: Cannot find module '@supabase/supabase-js' [line 2]

Which is strange, because I can actually use supabase with n8n, just fine. I just want to edit the way it is used as a vector store.

Any idea on how to resolve this issue?



Hi @Jelle_de_Rijke, from quickly taking a look at the n8n codebase it doesn’t look like n8n calls Supabase through a custom package, but instead simply sends the required HTTP requests directly to the Supabase API.

So if you’d like to use the @supabase/supabase-js you’d to install it first, then allow n8n to use it by setting the NODE_FUNCTION_ALLOW_EXTERNAL environment variable.

Thanks for your response. Based on this code from Github I suspect supabase-js is already present:

1 Like

Oh shoot, you’re right. I was only looking at the release version, not the AI beta :see_no_evil:. Sorry for the confusion.

Did you allow the use of this npm module through the environment variable? Perhaps @oleg can confirm if there are any other steps needed to use the module as part of n8n’s langchain functionality?

Yes the LangChain node works the same way as the Code-Node. All packages (except the LangChain one) as to be enabled via an environment variable.

Thanks for your response, Jan.

I have now set my env variables in railway like so:


I also tried adding them to the dockerfile.

But after redeploying I still get the same error. Perhaps I don’t understand correctly what you mean. I have used these docs: Configuration methods | n8n Docs

Thanks for any input in this regard. Super excited to try out Langchainjs in n8n instead of using Langchain Python in vscode!

The correct one should be @supabase/supabase-js. Can you please give that a try.


Amazing, Jan. Such a simple solution. Still getting my feet wet with nodejs :hugs:

Now let’s build!

Will post some example code here, once I get Supabase searchwithsimilarityscore running.


Glad to hear and thanks for giving back to the community!

1 Like

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