How to pnpm and Next.js in multi-stage docker file?

Viewed 4734
3 Answers

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

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.

Related