'How to fix "can not fin'd bcrypt" in NestJS?
As found in this SO-answer, the following thing could be a way how to encrypt a password into a hash:
@BeforeInsert() async hashPassword() {
this.password = await bcrypt.hash(this.password, Number(process.env.HASH_SALT));
}
However, although I have installed "bcrypt" and "types/bcrypt", it can't get found by NodeJS:
src/entities/user.entity.ts:50:27 - error TS2552: Cannot find name 'bcrypt'. Did you mean 'crypto'?
In my package.json the following lines show that bcrypt was successfully installed:
"@types/bcrypt": "^5.0.0",
"bcrypt": "^5.0.1",
How to fix this?
Solution 1:[1]
Import the bcrypt on the files where you use it like this:
import * as bcrypt from 'bcrypt';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ardritkrasniqi |
