argon2-browser icon indicating copy to clipboard operation
argon2-browser copied to clipboard

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

Open dwebfan opened this issue 2 years ago • 4 comments

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'

dwebfan avatar Mar 11 '22 02:03 dwebfan

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",
    ...
  }

Cajuteq avatar Jun 29 '22 17:06 Cajuteq

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

dangtony98 avatar Jan 29 '23 09:01 dangtony98

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;
}

glihm avatar Jan 30 '23 05:01 glihm

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

valerius21 avatar Jan 07 '24 18:01 valerius21