项目通过 vite 构建的,在使用 bcrypt 工具加密时,出现 Module "crypto" has been externalized for browser compatibility. Cannot access "crypto.randomBytes" in client code. See vitejs.dev/guide/troub… for more details.之后试了bcryptjs工具,也是有对应的警告。
在网上逛了一圈,基本都是说vite不支持,存在兼容性问题。
最后试了用根据crypto-js重写的crypto-es工具解决问题。