This error occurs when installing the sharp image processing library without libvips. Install libvips development files for your Linux distribution or use sharp's prebuilt binaries.
Sharp is a high-performance Node.js image processing library built on libvips. When npm can't find prebuilt binaries for your platform or they fail to work, it attempts to build from source and requires libvips to be installed. libvips is a fast image processing library written in C. Sharp needs either prebuilt binaries (which it tries first) or the libvips development files to compile against. This error typically occurs on less common platforms, older systems, or when network issues prevent downloading prebuilt binaries.
Install libvips and its development headers:
sudo apt-get update
sudo apt-get install -y libvips-devFor newer libvips versions (8.13+):
sudo apt-get install -y libvips-toolsFor Red Hat-based systems:
sudo yum install -y vips-develNote: CentOS 7 has an older vips. Consider using Remi's repository for newer versions:
sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum --enablerepo=remi install -y vips-develFor Alpine Linux (Docker):
apk add --no-cache vips-dev build-baseFor runtime only (after build):
apk add --no-cache vipsSharp can download prebuilt binaries. Ensure network access and try:
npm install sharp --ignore-scripts
npx sharp-cli installOr set the platform explicitly:
npm install --platform=linux --arch=x64 sharpIf libvips was installed after sharp, rebuild:
npm rebuild sharpOr clean install:
rm -rf node_modules/sharp
npm install sharpFor Docker multi-stage builds:
# Build stage
FROM node:20-alpine AS builder
RUN apk add --no-cache vips-dev build-base
WORKDIR /app
COPY package*.json ./
RUN npm ci
# Production stage
FROM node:20-alpine
RUN apk add --no-cache vips
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY . .Sharp supports these platforms with prebuilt binaries:
- linux-x64 (glibc, musl)
- linux-arm64 (glibc, musl)
- darwin-x64, darwin-arm64
- win32-x64
For ARM systems (Raspberry Pi), ensure you use the correct architecture:
npm install --arch=arm64 sharpIf you're behind a corporate proxy, the binary download may fail. Set npm proxy settings or install libvips locally.
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm