0

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"
});
Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

1

As it so happened, I ran into this issue today and found your question in an attempt to find a solution.

After trying a few different things, I discovered that using version 4.1.2 of http-auth (instead of the current 4.1.4, which is what your package.json has set in your GitHub repo) worked for me. So it seems to be a bug with the newer http-auth versions. I ran your code in your github repo but with version 4.1.2 of http-auth and it ran successfully.

  • thanks for the pointer, tried it and it worked for me in the big app as well. WiIl stay on 4.1.2 until this have been fixed in webpack or in node-rs (which appearantly is the source of the crash accordinng to https://github.com/webpack/webpack/issues/13053.) – Morgan Lindqvist Apr 06 '21 at 05:43
  • I have encountered the same problem and version 4.1.5 of http-auth fixed the problem. – Vydra21 Jun 02 '21 at 08:21
  • @Vydra21, yes 4.1.5 is working. I updated the http-auth and proposed a PR that was accepted and 4..1.5 was created. – Morgan Lindqvist Jun 06 '21 at 16:20
0

I have encountered the same problem and version 4.1.5 of http-auth fixed the problem.

Vydra21
  • 101
  • 1
  • 3