小编mik*_*866的帖子

如何使用 node-sharp for docker 运行 next.js

我在为 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 非常适合本地开发:

  • 下一个 12.0.1
  • 锐利0.30.2
  • 节点 16.xx
  • npm 8.xx
  • 操作系统 - macOS 蒙特利 - 12.2.1、M1 PRO

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)

docker next.js sharp

6
推荐指数
2
解决办法
8600
查看次数

标签 统计

docker ×1

next.js ×1

sharp ×1