antelle / argon2-browser

Argon2 library compiled for browser runtime
https://antelle.net/argon2-browser
MIT License
363 stars 78 forks source link

Module not found: Error: Can't resolve 'fs' in xxx #79

Open dwebfan opened 2 years ago

dwebfan commented 2 years ago

Got this failure in recent upgrade. I've tried some solutions, such as https://github.com/webpack-contrib/css-loader/issues/447, but unlucky so far. Can you help?

Compiled with problems:X

ERROR in ./node_modules/argon2-browser/dist/argon2.js 49:26-39

Module not found: Error: Can't resolve 'fs' in '/frontend/node_modules/argon2-browser/dist'
Cajuteq commented 2 years ago

Hi, I had the same problem and used browser compatible deps as placeholders for the fs, path, and crypto packages. Hopes this can help you.

  "dependencies": {
    ...  
    "crypto": "npm:crypto-browserify",
    "crypto-browserify": "^3.12.0",
    "fs": "npm:fs-browsers",
    "fs-browsers": "^1.1.6",
    "path": "npm:path-browserify",
    "path-browserify": "^1.0.1",
    ...
  }
dangtony98 commented 1 year ago

Wonder if there's a better way around this ... I'd prefer to stay away from introducing new dependencies to solve this issue.

@antelle would you have any solutions for this? - I'm running a Next.js application and need to use argon2-browser.

Edit:

The example provided in this repo worked perfectly for nextjs

glihm commented 1 year ago

Did you try to disable those in the package.json file?

"browser": {
    "fs": false
},

@dangtony98 the example you linked is doing exactly this in the configuration file next.config.js:

if (!isServer) {
  config.resolve.fallback.fs = false;
}
valerius21 commented 6 months ago

Could not find any of the solutions above to get them to work on NextJS 14. I'm using it with skiff-crypto