问题
I am working with:
- MacOS Mojave
- Angular 8
- node v12.12.0
- npm v6.13.4
and trying to make Argon2 to work in my Angular 8 app.
In order to use Argon2 it is required to install gcc and node-gyp globally. I did install them as indicated on the npm pages of Argon2. GCC v9 was installed. But, I had repeatedly problems executing:
CXX=g++-9 npm install
I kept getting errors about stdlib++ . I tried using Apple's CLang++ and got a successful build with:
CXX=clang++ npm install
I imported argon2 in my angular project in order to do password hashing and verification. Hashing seems to be working well (no errors) but as soon as I import argon2.verify() and use it in my code (by making a verify-call) I will get an error when trying to execute npm run start. Just trying to start the httpserver secured (ssl/tls) with corresponding private key and certificate.
The error I get is some mysterious error:
ERROR in ./node_modules/node-gyp-build/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/[username-deleted]/WebstormProjects/my-app/node_modules/node-gyp-build'
I have seen comments and complaints on probably similar problems on internet and people referring to some adjustment in a Webpack config file but at this point I dont have this config file in my project. I tried other versions of node-gyp-build but not resolved. Apparently argon2.hash() (its usage) is working without causing problems, but as soon as I introduce argon2.verify() in my code and run my app with npm run start I get the above error.
Any one with similar problem and how this problem was resolved?
回答1:
I had the same issue and fixed it by installing the Xcode Command Line Tools:
xcode-select --install
npm upgrade
npm install argon2 --save-dev
Hope it helps.
来源:https://stackoverflow.com/questions/59940800/argon2-is-difficult-to-get-working-with-angular-8-on-macos-actually-not-working