web-auth-library
web-auth-library copied to clipboard
Can't seem to import library
Hi,
Im trying to import the library using
import { getAccessToken } from "web-auth-library/google";
but I'm getting any error
./pages/api/tts_edge.ts:2:32
Type error: Cannot find module 'web-auth-library/google' or its corresponding type declarations.
1 | import { NextRequest } from "next/server";
> 2 | import { getAccessToken } from "web-auth-library/google";
| ^
3 |
4 | export const config = {
5 | runtime: "experimental-edge",
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What am I doing wrong?
@anirudhsama this library doesn't contain CJS code, just ESM:
https://github.com/kriasoft/web-auth-library/blob/42a722e4cedc09ea2a86f92fe5aed73b19e5de94/package.json#L60-L70
Maybe your bundler expects it to be CJS?
Oh that might be the case. I'm using it in a Nextjs Edge runtime.
I can only import it like this: import { verifyIdToken } from 'web-auth-library/dist/google'
Still running into this. package export is broken.
I have the same problem
I have the same problem. @maccman's import helped me get the library working though.
It might be related to how the exports are defined in package.json?
Top-level types
field is missing which might cause issues?
"exports": {
".": "./dist/index.js",
"./jwt": "./dist/core/jwt.js",
"./google": {
"types": "./dist/google/index.d.ts",
"import": "./dist/google/index.js",
"default": "./dist/google/index.js"
},
"./package.json": "./package.json"
},
Same issue here. Looks like there is a pending PR with a fix & few more issues opened all referencing this problem. Can this be fixed? Do you need help with that?
Likewise, still having this issue with types being missing.