argon2-browser: Cannot resolve 'env' in .../node_modules/argon2-browser/dist'

I am following the example you have for node in my React application. I have added const argon2 = require('argon2-browser'); and I am trying to make use of argon2.hash(...). I encounter the following error for some reason.

[1] [ error ] ./node_modules/argon2-browser/dist/argon2.wasm
[1] Module not found: Can't resolve 'env' in '/path/node_modules/argon2-browser/dist'

I am new to using WASM in node so perhaps it’s me not configuring things correctly. I have installed the npm module using npm install --save argon2-browser

Thank you for your time in advance!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Cool! It was a bit surprising that there are two configs, I thought, maybe one of them doesn’t work at all?

Hi - this might be of help for guys wanting to integrate argon2-browser into Vue.js. All i had to do was:

  • drop an additional webpack config into the root of the project. This will get merged with Vue’s basic webpack setup:

vue.config.js:


module.exports = {
  configureWebpack: {
    module: {
      noParse: /\.wasm$/,
      rules: [
          {
              test: /\.wasm$/,
              loaders: ['base64-loader'],
              type: 'javascript/auto'
          }
      ]
  }
  }
}
  • Adding the base64 encoder as a dependency:

package.json:

-    "argon2-browser": "^1.6.0"
+    "base64-loader": "^1.0.0",
+    "argon2-browser": "^1.9.0"
   },