-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Importing decode
function from jsonwebtoken causes error
#954
Comments
Hi @michaelmendoza , |
@Qolzam I just used a different library: jwt-decode. Ideally, they would just fix the issue in node-jsonwebtoken. But both libraries are by the same organization. |
Also having the same issue on version |
Yeah I had this, in my case it's caused by me trying to run it in the browser. Run it on a node.js server - not a browser - and it's fine.Maybe:
|
same problem. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Importing
decode
function from jsonwebtoken causes error. I am unable to import the 'decode' function as normal.I suspect that this is an issue with vite and svelte. Seems the package safe-buffer, that jsonwebtoken is dependant on, is doing something vite doesn't like saying
Module externalized for browser compatibility
meaning it is likely using a Node.js module that is not polyfilled in and the vite doesn't accept. That is just my guess. (See vite info on issue here. )If you make node-jsonwebtoken work with strict mode with all it's dependencies, this may fix this probelm.
Reproduction
In my code I used the following:
import { decode, sign } from 'jsonwebtoken';
I get the following errors:
Looking into the chrome debugger and stopping the code before the error it seems that it has to do with the package safe-buffer that jsonwebtoken is dependant on.
Environment
Using svelte (v4.0.5) with vite (v4.4.2) on macOS and test with Chrome browser (v120).
The text was updated successfully, but these errors were encountered: