Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import npm module fail #78

Closed
1 of 2 tasks
okxiaoliang4 opened this issue May 1, 2023 · 17 comments
Closed
1 of 2 tasks

import npm module fail #78

okxiaoliang4 opened this issue May 1, 2023 · 17 comments
Labels
C-bug Category: something isn't working

Comments

@okxiaoliang4
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

2023-05-01 15:54:13 worker thread panicked Unsupported scheme "npm" for module "npm:[email protected]". Supported schemes: [
2023-05-01 15:54:13     "data",
2023-05-01 15:54:13     "blob",
2023-05-01 15:54:13     "file",
2023-05-01 15:54:13     "http",
2023-05-01 15:54:13     "https",
2023-05-01 15:54:13 ]

To Reproduce

import OSS from "npm:[email protected]";

Expected behavior

import npm module successful

Screenshots

image

System information

  • MacOS
  • Edge
  • supabase-js: 2.21.0
  • Node.js: v18.14.0

Additional context

Add any other context about the problem here.

@okxiaoliang4 okxiaoliang4 added the C-bug Category: something isn't working label May 1, 2023
@mindblight
Copy link

I'm running into the same issue. Some of the esm.sh files aren't working due to incorrect node polyfills. I'm hoping that importing the "official" way would be a workaround, but I'm hitting the same problem with the edge functions

@zdanl
Copy link

zdanl commented Jun 3, 2023

I'm trying to import https://esm.sh/[email protected] and create an Ethereum wallet by calling const wallet = ethers.Wallet.createRandom() in an Edge Function, but despite near instant deployment time, I get an Internal Server Error:

TypeError: Expected instance of class which extends utils.Hash at new E (https://esm.sh/v124/@noble/[email protected]/deno/pbkdf2.js:2:2102) at Function.H.create (https://esm.sh/v124/@noble/[email protected]/deno/pbkdf2.js:2:3177) at O (https://esm.sh/v124/@noble/[email protected]/deno/pbkdf2.js:2:3423) at X (https://esm.sh/v124/@noble/[email protected]/deno/pbkdf2.js:2:3653) at go (https://esm.sh/v124/[email protected]/deno/ethers.mjs:2:34498) at vo (https://esm.sh/v124/[email protected]/deno/ethers.mjs:2:35665) at mt (https://esm.sh/v124/[email protected]/deno/ethers.mjs:2:35754) at Ft.computeSeed (https://esm.sh/v124/[email protected]/deno/ethers.mjs:5:7795) at Function.createRandom (https://esm.sh/v124/[email protected]/deno/ethers.mjs:5:17213) at Function.createRandom (https://esm.sh/v124/[email protected]/deno/ethers.mjs:5:20684)

It works fine locally.

@chingiz
Copy link

chingiz commented Jun 15, 2023

I am having the same problem. Everything works locally by running deno run index.ts

@Pictor13
Copy link

Mmmh, am I hallucinating or actually Supabase mentioned recently that they (at least for now) dropped the NPM support flag from Deno?

You can see in this other issue of mine that (inside local-dev docker created by supabase start) the Deno CLI is being called with the --no-npm option.

I think you'll have to focus on figuring out how to correctly fetch dependencies from esm.sh (or another Deno-friendly CDN).

@chief-nerd
Copy link

Waiting for npm support -- for Firebase Cloud Messaging (Notifications) ... kinda a big missing thing. :/

@chief-nerd
Copy link

chief-nerd commented Jul 3, 2023

@Pictor13 you mean this comment here from @laktek
https://github.com/orgs/supabase/discussions/7742#discussioncomment-5375195

NPM support would be such a great thing -- it would eliminate a lot of problems with missing dependencies.
Should be high priority.

And here the corresponding open issue on denoland
denoland/deploy_feedback#314

@barbinbrad
Copy link

barbinbrad commented Sep 29, 2023

+1 for npm:<package>@<version> imports.

https://deno.com/blog/npm-on-deno-deploy

@AndersonMamede
Copy link

AndersonMamede commented Sep 29, 2023

+1 for adding Deno's native npm support. For now it seems #82 (comment) will work to use firebase-admin lib

Edit: nope, I couldn't make it work =/

@Maxim-Filimonov
Copy link

Meanwhile https://deno.com/blog/npm-on-deno-deploy. I thought that supabase edge runtime is based off deno deploy. Does it mean we can expect supabase to add support soon too?

@kerren
Copy link

kerren commented Oct 14, 2023

I agree with @Maxim-Filimonov, I think it's a major selling point to support npm modules (in Deno) and that's a major win for Supabase as well!

Hopefully, we'll see this enabled soon!

@Aadim1
Copy link

Aadim1 commented Oct 16, 2023

https://supabase.com/changelog. I can see here that they are using npm:@supabase.. to import { createClient } so I am guessing its in the work. Is there any timeline? I can continue developing locally for the time being, if its going to be supported soon.

@laktek
Copy link
Contributor

laktek commented Oct 16, 2023

Yep, this is currently worked on. I can't provide an accurate an ETA for it as there are few unknowns at the moment. Will post an update when we have some progress.

@Aadim1 unfortunately that example wouldn't work in Supabase edge functions yet :(

@Aadim1
Copy link

Aadim1 commented Oct 16, 2023

@laktek Thanks for the quick reply. Happy to know its in active development. Cheers.

@eliasljubec
Copy link

Native npm support would be crucial for supabase edge functions - perhaps any news? @laktek

@localhosted
Copy link

With the recent announcement here, does edge-runtime already support npm modules?

@laktek
Copy link
Contributor

laktek commented Dec 13, 2023

yes, importing npm modules with npm: specifier is now supported in edge-runtime.

@laktek laktek closed this as completed Dec 13, 2023
@ekatzenstein
Copy link

How would this work with a nextjs project? Haven't found anything in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

No branches or pull requests