0

I have an Angular project where I want to use argon2 library to encrypt passwords. I added it to the back end, the implementation it's fine but my Angular front end app started to break.

I get a huge list of errors like:

ERROR in /<project>/node_modules/argon2/node_modules/minizlib/constants.js
Module not found: Error: Can't resolve 'zlib' in '/<project>/node_modules/argon2/node_modules/minizlib'

This is just one of the errors, I have similar errors for modules like crypto, fs, http, https, os, path, stream and many others. Same happens if I use bcrypt.

Do you know what is issue?

chenny
  • 769
  • 2
  • 17
  • 44

1 Answers1

0

Angular doesn’t support working with node js modules Like fs and more. U could find a package for encrypting password from npm to do the work instead.

waseemrakab
  • 315
  • 2
  • 9
  • Yeah, the thing is my project is an NX mono repo and I was importing something from a backend lib that brought in the angular code also the crypto lib and then my build was failing. I solved duplicating some code. But for whom has the same problem I can suggest `crypto-js` to hash passwords in the frontend (but I've been told that's not a good practice). – chenny Nov 18 '20 at 14:42
  • @chenny [Another SO post](https://stackoverflow.com/a/21716654/8740349) proves hashing-passwords to be **best but maybe too hard** practice. – Top-Master Jun 09 '22 at 06:37