Skip to content

# 优化后的 Dockerfile FROM node:18-alpine AS builder 版本过低 报错 ai让用20 #2

@corsgoo

Description

@corsgoo

白了,你遇到的这个问题其实是node 版本与 better-sqlite3 不兼容,以及Docker 构建过程中找不到 Python,导致 npm ci --only=production 失败。具体原因分析:

Node 版本问题

better-sqlite3 12.2.0 需要 Node 20.x 或以上,而你 Dockerfile 里用的是 node:18-alpine。

报错信息里明确写了:

css
复制代码
required: { node: '20.x || 22.x || 23.x || 24.x' },
current: { node: 'v18.20.8' }
Python 缺失问题

better-sqlite3 在安装时会调用 node-gyp 编译,如果找不到 Python 会报错。

虽然 Dockerfile 里你安装了 python3,但 Alpine 需要额外设置 python3 命令或软链接。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions