I have a large NodeJS application that have been working just fine after beeing processed by Webpack-5. Now I added http-auth and then the application crashes.
On https://github.com/MorganLindqvist/webpack5-http-auth-failure you can find a very minimalistic version of the app that crashes in the same when executed after Webpack5.
Here is an example of when it works (without webpack 5) and then when it crashes (with webpack 5).
git clone https://github.com/MorganLindqvist/webpack5-http-auth-failure.git
cd webpack5-http-auth-failure
npm install
node src/index.js
This works as it should, nothing significant happens. If using webpack5 it does however not work, instead it crashes.
npm run build_dev
node dist/main.js
The error message is as follows:
TypeError: Can not find node binding files from @node-rs/bcrypt-linux-x64-gnu, @node-rs/bcrypt-linux-x64-gnux32, @node-rs/bcrypt-linux-x64-musl and /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-gnu.node, /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-gnux32.node, /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-musl.node
When installing http-auth I get a number of warnings looking like this:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @node-rs/bcrypt-android-arm64@1.2.1 (node_modules/@node-rs/bcrypt-android-arm64): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @node-rs/bcrypt-android-arm64@1.2.1: wanted {"os":"android","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
Now to my question: Is this a bug in http-auth, webpack5, or on my side?
I have been trying to understand the warnings and error but I have not found anything helpful when searching for similar issues.
As I said, I have a big project and it crashes with the exact same error as when I have removed everything except the following lines in index.js.
const auth = require("http-auth");
const basic = auth.basic({
realm: "Docker registry",
file: __dirname + "/../htpasswd"
});