Importing `decode` function from jsonwebtoken causes error
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, vite
- Ambito
- web-dev
Direzione di ricerca
Riproduci l'importazione nella configurazione segnalata con Svelte 4.0.5/Vite 4.4.2 e Chrome. Inizia da node_modules/safe-buffer/index.js e segui lo stack attraverso jws/lib/sign-stream.js, jsonwebtoken/decode.js e jsonwebtoken/index.js; il lavoro è completato quando l'importazione di decode non genera più l'errore del browser segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
Provide a clear and concise description of the issue, including what you expected to happen.
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:
app.js:28 TypeError: Cannot read properties of undefined (reading 'from')
at node_modules/safe-buffer/index.js (jsonwebtoken.js?v=1203475a:28:17)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jws/lib/sign-stream.js (jsonwebtoken.js?v=1203475a:591:19)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jws/index.js (jsonwebtoken.js?v=1203475a:771:22)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jsonwebtoken/decode.js (jsonwebtoken.js?v=1203475a:804:15)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jsonwebtoken/index.js (jsonwebtoken.js?v=1203475a:4397:15)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
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).
- Lingua principale
- JavaScript
- Stelle
- 18.2k
- Fork
- 1.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di auth0/node-jsonwebtoken
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
auth0/node-jsonwebtoken#1042 · 1 commento ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
auth0/node-jsonwebtoken#1000 · 2 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 65/100
auth0/node-jsonwebtoken#1046 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
auth0/node-jsonwebtoken#1034 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
auth0/node-jsonwebtoken#1032 ·
Tutte le issue di auth0/node-jsonwebtoken
Issue simili
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/safe-publish#594 ·
-
内部文件键(绝对路径的 base64)泄漏到界面标签 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NousResearch/hermes-agent#121143 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100