Resolving Argon2 "No native build found" Error in Production

When deploying Node.js applications that use the argon2
package for password hashing, you might encounter this error:
⨯ Error: No native build was found for platform=linux arch=x64 runtime=node abi=127 uv=1 libc=glibc node=22.6.0
loaded from: /app/node_modules/argon2
at load.resolve.load.path (/app/node_modules/node-gyp-build/node-gyp-build.js:60:9)
at load (/app/node_modules/node-gyp-build/node-gyp-build.js:22:30)
at Object.<anonymous> (/app/node_modules/argon2/argon2.cjs:7:32)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12)
This occurs because the pre-built binary for argon2
is incompatible with your Docker environment. Here's how to fix it:
The Solution: Build from Source
Modify your Dockerfile to build argon2
from source during the image creation process. Here's an example:
FROM node:22-slim AS base
# Install build essentials
RUN apt-get update && apt-get install -y python3 make g++
FROM base AS deps
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild argon2
RUN npm rebuild argon2 --build-from-source
# ... rest of your Dockerfile
Resolving Argon2 "No native build found" Error in Production

When deploying Node.js applications that use the argon2
package for password hashing, you might encounter this error:
⨯ Error: No native build was found for platform=linux arch=x64 runtime=node abi=127 uv=1 libc=glibc node=22.6.0
loaded from: /app/node_modules/argon2
at load.resolve.load.path (/app/node_modules/node-gyp-build/node-gyp-build.js:60:9)
at load (/app/node_modules/node-gyp-build/node-gyp-build.js:22:30)
at Object.<anonymous> (/app/node_modules/argon2/argon2.cjs:7:32)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12)
This occurs because the pre-built binary for argon2
is incompatible with your Docker environment. Here's how to fix it:
The Solution: Build from Source
Modify your Dockerfile to build argon2
from source during the image creation process. Here's an example:
FROM node:22-slim AS base
# Install build essentials
RUN apt-get update && apt-get install -y python3 make g++
FROM base AS deps
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild argon2
RUN npm rebuild argon2 --build-from-source
# ... rest of your Dockerfile