Beginner: How to Update Supabase Database from Typescript
Sorry for the beginner question. I'm a database person who's new to javascript (and app development in general).
I'm having trouble initializing my connection to Supabase from javascript. I've tried the method described here (https://supabase.com/docs/reference/javascript/initializing) and in screenshot, but it gives me this error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@supabase/supabase-js' imported from C:\Git\Supabase\supabase\functions\hexnode_db_update\index.ts
Am I just missing some basic component of how you do library imports in js?
JavaScript: Initializing | Supabase Docs
Supabase API reference for JavaScript: Initializing

4 Replies
That won't work unless you are using Vite or something like that or
.mjs files. It's probably best to show what you are trying to use this in.Do
npm installI tried "npm install supabase" and that didn't do it.
The goal is to trigger off a new line in a table, call an external API to pull a bunch of information, and then fill up the rest of the columns in that table with the additional information. Here are a couple of scripts in progress that do some of that.
The API call is fine, and I think I can figure out the json parsing. The thing I'm really missing is the connection to postgres so I can run the row update.
The API call is fine, and I think I can figure out the json parsing. The thing I'm really missing is the connection to postgres so I can run the row update.


Turns out @DevsrealmGuy was right, but I had to run the full npm install @supabase/supabase-js.
Also, running as an .mjs file avoided a bunch of warnings. Thanks!
Also, running as an .mjs file avoided a bunch of warnings. Thanks!