The official Next.js Dockerfile example does not work if I switch npm to pnpm.
How should I modify that Dockerfile so that it remains multi-stage, but also uses pnpm instead of npm?
The official Next.js Dockerfile example does not work if I switch npm to pnpm.
How should I modify that Dockerfile so that it remains multi-stage, but also uses pnpm instead of npm?
 
    
    Another solution is installing pnpm using npm. When you install nodejs it comes with npm as the default package manager. So you can install pnpm using npm using the following command npm install -g pnpm
In the docker file it will be written as;
RUN npm install -g pnpm
 
    
     
    
    What worked for me is the following:
FROM node:16-alpine AS base
RUN apk update && apk add --no-cache libc6-compat
RUN corepack enable && corepack prepare pnpm@7.4.1 --activate 
...
The above assumes that you're using either >=Node 16.9 or >=Node 14.19; that has the corepack command built-in.
 
    
    I know I'm a bit late, but this is what worked for me:
RUN apk add --no-cache curl \
    && curl -sL https://unpkg.com/@pnpm/self-installer | node
 
    
    What worked for me is the following:
FROM node:16.16.0-alpine3.16
RUN corepack enable
RUN corepack prepare pnpm@7.18.0 --activate
 
    
    