我在为 Dockerfile 实现 Sharp 时遇到问题。
Error: 'sharp' is required to be installed in standalone mode for the image
optimization to function correctly
Run Code Online (Sandbox Code Playgroud)
Next.js 和 Sharp 非常适合本地开发:
next.config.js
module.exports = {
experimental: {
outputStandalone: true,
},
Run Code Online (Sandbox Code Playgroud)
}
Dockerfile:
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# …Run Code Online (Sandbox Code Playgroud)