You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run your application e.g. via nodemon - everything works fine
run your application via serverless (after creating a webpack build) -> an error is thrown.
Expected behaviour
I'm having issues using argon2 in my project when building it with webpack and running it with serverless.
The following lines in the argon2.js file seem to be a problem for webpack (webpack cannot resolve dynamic imports/requires):
Any suggestions how to fix this? (is there anything I can do differently?)
Actual behaviour
Error: Cannot find module '/[....]/node_modules/argon2/package.json'
at webpackEmptyContext (/[....]/packages/server/.webpack/service/dist/src/webpack:/[....]/node_modules/node-pre-gyp/lib sync:2:1)
at Object.module.exports.../../node_modules/node-pre-gyp/lib/pre-binding.js.exports.find (/[....]/packages/server/.webpack/service/dist/src/webpack:/[....]/node_modules/node-pre-gyp/lib/pre-binding.js:20:23)
at Object.<anonymous> (/[....]/packages/server/.webpack/service/dist/src/webpack:/[....]/node_modules/argon2/argon2.js:8:1)
at Object.../../node_modules/argon2/argon2.js (/[....]/packages/server/.webpack/service/dist/src/serverless.js:31908:30)
at __webpack_require__ (/[....]/packages/server/.webpack/service/dist/src/webpack:/webpack/bootstrap:19:1)
Environment
Operating system: MacOS - Catalina 10.15.5
Node version: v12.17.0 Webpack version:* 4.42.0
Reacted by Branden Silva, Alex Watson and strongui
I'm sorry, but a change in the webpack.config.js fixed the problem.
Instead of: externals: [nodeExternals()],
I needed to include argon2 explicitly in the externals:
Activity
jayd-mh commentedon Jun 5, 2020
I'm sorry, but a change in the webpack.config.js fixed the problem.
Instead of:
externals: [nodeExternals()],I needed to include argon2 explicitly in the externals:
ranisalt commentedon Jun 5, 2020
Can you update the README or create an article in the wiki for us? :)
jayd-mh commentedon Jun 5, 2020
I'm not quite sure if it is the right way to do it (or just a workaround).
But as soon as I am sure, I will provide you the information!
Directly import binary
haywirez commentedon Jun 19, 2023
After a few hours wasted, the below config finally works for me 😉 Specifying the
commonjs ${libraryName}externals type for webpack was crucial.di-sukharev commentedon Nov 7, 2024
i used Bun.password.hash(), it uses argon2 under the hood and it just works