skip to content
Chris Vaillancourt

Using pnpm With Cloudflare Pages

TLDR

This community post offers an effective solution:

  1. add an environment variable to the build settings that skips the npm install: NPM_FLAGS = --version
  2. install pnpm and cache the pnpm store: npx pnpm i --store=node_modules/.pnpm-store && npm run build

The problem with pnpm on Cloudflare Pages

While deploying this site to Cloudflare pages, I ran into a challenge with using this project’s default build command: pnpm build.

The issue is Cloudflare pages uses npm for Astro projects so executing pnpm build fails spectacularly. The docs (as of September 2022) don’t provide any insight or recommendations for using pnpm as a package manage.

Fortunately, a community post offers an effective solution.