I'd like to use the NPM library web-push in my functions

If I import the web-push library into a TS Pages function it fails as the library includes a require("https") call. Wrangler tells me that https is built-in, but that I need to enable Node compatibility and use the “node:” prefix on the require.

What’s the best way to get this working? I don’t want to re-invent the wheel.

2 Likes

I’m struggling with the same problem.
Would love to hear an answer.

1 Like

I replaced web-push with webcrypto-web-push, and it works!

And remember to add node_compat = true to wrangler.toml