node.jstypescriptnpm-installnpm-packagebcryptjs

Cannot find module 'bcryptjs'


I installed @types/bcryptjs package in nodejs. When I import it only, there is no problem but when I use it in my code, like that:

console.log(bcrypt.hashSync(req.body.password))

it gives me an error; Cannot find module 'bcryptjs'

What do I do?

I tried npm rebuild I uninstalled this package and reinstalled it But it didn't work


Solution

  • If you installed only @types/bcryptjs, you also need to install the library itself:

    npm install bcryptjs