Closed DitlevHB closed 1 year ago
That sounds like you're trying to run supabase function deploy
directly rather than the command specified in package.json https://github.com/langchain-ai/langchain-template-supabase/blob/main/package.json#L9
True, which is also totally doable (if you know what you are doing, which I seemingly don't). In short, make sure to use import_map_deploy.json when deploying and not the one for development.
Why?
The true culprit of this has been the inclusion of definition files that is part of the langchain esm file "https://esm.sh/langchain@0.0.56/".
The build.ts file that supabase uses cannot handle this and spews out the error that I initially listed.
The Fix: Use the suffix/option "&no-dts" when referencing the ESM module from the import_map_deploy to exclude the definition files.
Suggestion: Mention this in notes of this example project (usage of langchainJS with supabase). It can help those who would like to implement this into an existing project from making the same mistake as I.
Yes that's right. I'm open to adding that explanation to the readme if you want to do so, in the end this is just a Supabase CLI issue that we're working around,
I am getting the following error message when trying to deploy a function with supabase that uses LMMChain from langchainjs.
error: Uncaught (in promise) Error: Relative import path "events" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v115/@types/node@18.15.11/events.d.ts" const ret = new Error(getStringFromWasm0(arg0, arg1)); ^ at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894) at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6) at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)
If I remove the import statement
import { LLMChain } from "langchain/chains";
The deployment is successful.
I have tried adding events to my import_map.json file, but then I get a similar error for another package. Seems like the @types/node frequently uses the "require" function which is causing some trouble here because the import path (function param of require) is not found in the import_map.
I should add that it works when executing deno run on the file using the same import_map.
Any ideas on how to fix this?