簡體   English   中英

找不到模塊:使用 jsonwebtoken package 時無法解析導入的依賴項“crypto”

[英]Module not found: Can't resolve imported dependency "crypto" when using jsonwebtoken package

我正在使用 quasar cli 創建一個 vue 3 應用程序。 我已經通過紗線安裝了 jsonwebtoken。 當我嘗試編譯應用程序時,我收到下面列出的錯誤:

App •  ERROR  •  UI  in ./node_modules/jwa/index.js

Module not found: Can't resolve imported dependency "crypto"
Did you forget to install it? You can run: yarn add crypto

 App •  ERROR  •  UI  in ./node_modules/jwa/index.js

Module not found: Can't resolve imported dependency "util"
Did you forget to install it? You can run: yarn add util

 App •  ERROR  •  UI  in ./node_modules/jws/lib/data-stream.js

Module not found: Can't resolve imported dependency "stream"
Did you forget to install it? You can run: yarn add stream

 App •  ERROR  •  UI  in ./node_modules/jws/lib/data-stream.js

Module not found: Can't resolve imported dependency "util"
Did you forget to install it? You can run: yarn add util

我可以運行“yarn add util”和“yarn add stream”以及那些錯誤 go ,但我不知道這是否是問題的正確解決方案。 無論如何,我不能只運行“yarn add crypto”來解決該錯誤。 當你這樣做時,你會收到以下警告......

warning crypto@1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.

但我不確定這里需要做什么才能“切換到內置的”,並且很好奇是否每個人在使用 jsonwebtoken 時都會遇到這個問題?

我一直無法弄清楚如何解決我在嘗試使用 jsonwebtoken 時遇到的問題。 我還嘗試了其他幾個 JWT 包,但也沒有成功。 最后我遇到了 jwt-decode ,因為我在客戶端上唯一需要做的就是解碼我嘗試過的令牌,它工作得很好並且非常易於使用:

https://www.npmjs.com/package/jwt-decode

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM