Can't use createClient in Edge Function (can't find tslib)

Below is my code. I have confirmed that the env vars are set. The error is specifically coming from the createClient line .. when I comment it out, there's no error. The specific error is this:
event loop error: Error: Cannot find module 'tslib' Require stack: - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/FunctionsClient.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/index.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/supabase-js/2.76.0/dist/main/SupabaseClient.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/supabase-js/2.76.0/dist/main/index.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/supabase-js/2.76.0/dist/main/index.js at Function.Module._resolveFilename (node:module:619:15) at Function.Module._load (node:module:497:27) at Module.require (node:module:681:19) at require (node:module:818:16) at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/FunctionsClient.js:4:17) at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/FunctionsClient.js:132:4) at Module._compile (node:module:745:34) at loadMaybeCjs (node:module:770:10) at Object.Module._extensions..js (node:module:755:12) at Module.load (node:module:662:32)
event loop error: Error: Cannot find module 'tslib' Require stack: - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/FunctionsClient.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/index.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/supabase-js/2.76.0/dist/main/SupabaseClient.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/supabase-js/2.76.0/dist/main/index.js - /var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/supabase-js/2.76.0/dist/main/index.js at Function.Module._resolveFilename (node:module:619:15) at Function.Module._load (node:module:497:27) at Module.require (node:module:681:19) at require (node:module:818:16) at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/FunctionsClient.js:4:17) at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/@supabase/functions-js/2.76.0/dist/main/FunctionsClient.js:132:4) at Module._compile (node:module:745:34) at loadMaybeCjs (node:module:770:10) at Object.Module._extensions..js (node:module:755:12) at Module.load (node:module:662:32)
And here is the code
import { createClient } from 'npm:@supabase/supabase-js@2';

Deno.serve(async (req)=>{
const supabaseAdmin = createClient(
Deno.env.get('SUPABASE_URL') ?? '', Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? ''
);

return new Response(JSON.stringify("it works"), {
status: 200,
headers: {
'Content-Type': "application/json",
'Connection': 'keep-alive'
}
});
});
import { createClient } from 'npm:@supabase/supabase-js@2';

Deno.serve(async (req)=>{
const supabaseAdmin = createClient(
Deno.env.get('SUPABASE_URL') ?? '', Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? ''
);

return new Response(JSON.stringify("it works"), {
status: 200,
headers: {
'Content-Type': "application/json",
'Connection': 'keep-alive'
}
});
});
4 Replies
garyaustin
garyaustin6h ago
There is a bug potentially in 1.76.0 released earlier today.
garyaustin
garyaustin6h ago
GitHub
Cannot find module 'tslib' · Issue #1788 · supabase/supabase-js
Describe the bug Unable to run my javascript file when using the latest version of supabase-js, 2.76.0. When rolling back to the previous version, 2.75.1, the issue goes away. Happening both locall...
skamz
skamzOP6h ago
Thank you for letting me know! Confirmed that using import { createClient } from 'npm:@supabase/supabase-js@2.75.1'; does seem to fix it. Awesome
garyaustin
garyaustin6h ago
Please add comment at link and mention edge functions impacted.

Did you find this page helpful?