【问题标题】:TypeError: Cannot read property of 'hash' of undefined in argon2 and bcryptTypeError:无法读取 argon2 和 bcrypt 中未定义的“哈希”属性
【发布时间】:2022-01-11 02:25:21
【问题描述】:

我正在使用 Nestjs,并尝试了 argon2bcrypt 两个库。

import argon2 from 'argon2'import bcrypt from 'bcrypt' 都导致相同的错误。

当我将鼠标悬停在 userDto.password = await argon2.hash(userDto.password); 中的hash 上时,我可以看到该属性存在,但我不断收到错误消息。


是的,有很多关于bcrypt 中的问题的问题,在大多数情况下是由从bcryptjs 导入引起的。

我尝试清除 npm 和 yarn 缓存,多次删除并重新安装 node_modules。

但它们似乎不适用于argon2bcrypt

【问题讨论】:

    标签: node.js nestjs bcrypt argon2-ffi


    【解决方案1】:

    试试这个:

    import * as argon2 from "argon2";
    
    const hash = await argon2.hash(..);
    

    【讨论】:

      猜你喜欢
      • 2020-03-07
      • 2022-06-19
      • 2021-12-08
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 2020-11-29
      相关资源
      最近更新 更多