pnpm fetch
將套件從 lockfile 提取到虛擬儲存庫中,忽略套件資訊清單。
使用範例
此命令專門用於改進創建 docker 的映像。
You may have read the official guide to writing a Dockerfile for a Node.js app, if you haven't read it yet, you may want to read it first.
From that guide, we learn to write an optimized Dockerfile for projects using pnpm, which looks like
FROM node:20
WORKDIR /path/to/somewhere
RUN corepack enable pnpm && corepack install -g pnpm@latest-9
# Files required by pnpm install
COPY .npmrc package.json pnpm-lock.yaml .pnpmfile.cjs ./
# If you patched any package, include patches before install too
COPY patches patches
RUN pnpm install --frozen-lockfile --prod
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "node", "server.js" ]