Alister
Alister•15h ago

How to import library in Edge Function ?

Hey Good afternoon ! I would like to export my function in an edge function to execute it in the back. I'm using supabase and I installed deno to do that. I would like to import my libraries like my initial function but deno it's different...
import { JWT } from 'google-auth-library';
import { GoogleSpreadsheet } from 'google-spreadsheet';


import { JWT } from "https://esm.sh/google-auth-library@8.7.0";
import { GoogleSpreadsheet } from "https://esm.sh/google-spreadsheet@3.3.0";
import { JWT } from 'google-auth-library';
import { GoogleSpreadsheet } from 'google-spreadsheet';


import { JWT } from "https://esm.sh/google-auth-library@8.7.0";
import { GoogleSpreadsheet } from "https://esm.sh/google-spreadsheet@3.3.0";
I need both of these libraries to my function but I don't how I'm suppose to import them. I read on forum, I need to use CDN for that but I don't know how it works :/ If someone could help me it will be wonderful ^^ Btw sorry for my english 😉
2 Replies
marvinh.
marvinh.•14h ago
Just import them like you would normally. With Deno 2 npm support pretty good which means you don't need to go to alternative registries like esm.sh.
Alister
Alister•13h ago
Hey @marvinh. , thanks for you answer 😉 I did what you said but when I tried to deploy the function, all is good, buit when I tried to use it I have this error :
worker boot error: Relative import path "google-auth-library" not prefixed with / or ./ or ../
worker boot error: Relative import path "google-auth-library" not prefixed with / or ./ or ../
I used this import to the test :
import { JWT } from 'google-auth-library';
import { GoogleSpreadsheet } from 'google-spreadsheet';
import { JWT } from 'google-auth-library';
import { GoogleSpreadsheet } from 'google-spreadsheet';
(I checked I jave deno 2.0.0 ) okay it works with 'npm:google-auth-library'