The ENOTSUP libc error occurs when npm packages with native binaries are built for glibc but your system uses musl (or vice versa). This commonly happens with Alpine Linux Docker images. Switch to a glibc-based image or rebuild packages from source.
This error occurs when npm tries to install a package with prebuilt native binaries that were compiled for a different C library than your system uses. Linux systems use one of two main C libraries: glibc (GNU C Library, used by Debian, Ubuntu, CentOS) or musl (used by Alpine Linux). When a package like Sharp, bcrypt, or esbuild publishes prebuilt binaries, they're compiled against a specific libc. If you're running Alpine Linux (musl) but the package only has glibc binaries available, npm cannot install the prebuilt version and reports this ENOTSUP error. This is particularly common in Docker environments where Alpine images are popular for their small size, but many npm packages don't provide musl-compatible prebuilds.
The simplest fix is to use a Debian or Ubuntu-based Node.js image instead of Alpine:
# Instead of this (Alpine/musl):
FROM node:20-alpine
# Use this (Debian/glibc):
FROM node:20
# or
FROM node:20-slimThe official node:20 and node:20-slim images use Debian with glibc, which is compatible with most npm packages.
If you must use Alpine, install the glibc compatibility package:
FROM node:20-alpine
RUN apk add --no-cache libc6-compatThis provides a compatibility layer that allows some glibc-built binaries to run on musl systems. Note: this doesn't work for all packages.
Force npm to compile native modules on your system instead of using prebuilds:
FROM node:20-alpine
# Install build dependencies
RUN apk add --no-cache python3 make g++
# Force rebuild from source
RUN npm install --build-from-sourceThis compiles the native code against your system's libc, ensuring compatibility.
Explicitly tell npm which platform to target:
npm install --cpu=x64 --os=linux --libc=glibcThis is useful in CI systems where the build environment differs from the deployment target.
If you copied node_modules between systems, delete and reinstall:
rm -rf node_modules package-lock.json
npm installNative modules must be installed on the target system, not copied from another environment.
Some packages provide specific Alpine installation instructions. For example, Sharp recommends:
FROM node:20-alpine
RUN apk add --no-cache vips-devCheck the package's GitHub repository or npm page for platform-specific guidance.
The glibc vs musl incompatibility is a fundamental architectural difference, not just a missing dependency. musl is designed for simplicity and small size (making Alpine images ~5MB vs ~100MB for Debian), but this comes at the cost of binary compatibility.
For AWS Lambda, the runtime uses Amazon Linux (glibc). If you build your deployment package on Alpine, native modules will fail at runtime. Always build Lambda packages on a glibc-based system or use the official AWS SAM build containers.
Some packages like esbuild handle this gracefully by publishing separate npm packages for each platform (@esbuild/linux-x64, @esbuild/linux-arm64, etc.). If you see errors about missing @package/linux-x64-musl, the package may not support your platform at all.
For production deployments, consider whether Alpine's smaller image size is worth the complexity. A 100MB Debian image that works reliably is often better than a 5MB Alpine image that requires extensive workarounds.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error