Importing `decode` function from jsonwebtoken causes error
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, vite
- 領域
- web-dev
調査の方向性
報告された Svelte 4.0.5/Vite 4.4.2 のセットアップと Chrome で import を再現します。node_modules/safe-buffer/index.js から始め、jws/lib/sign-stream.js、jsonwebtoken/decode.js、jsonwebtoken/index.js を通してスタックを追跡します。decode の import で報告されたブラウザーエラーが発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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).
- 主要言語
- JavaScript
- スター
- 18.2k
- フォーク
- 1.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
auth0/node-jsonwebtoken のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
auth0/node-jsonwebtoken#1042 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
auth0/node-jsonwebtoken#1000 · コメント 2 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
auth0/node-jsonwebtoken#1048 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 65/100
auth0/node-jsonwebtoken#1046 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
auth0/node-jsonwebtoken#1034 ·
auth0/node-jsonwebtoken の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
Design only Leadership Survey SLFS
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
bcgov/digital-journeys#2293 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
tursodatabase/turso#9405 ·
メンテナーはふだん 1 日以内に返信
-
Toolkit
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
API Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ProjectSidewalk/SidewalkWebpage#5556 ·
メンテナーはふだん 1 日以内に返信