Skip to content

Publishing a pnpm project on Cloudflare Pages

Published: 5 months ago

There are several options for managing node/JS/TS projects, and not all of them are enabled within the Cloudflare Pages build process. While there is a Community Feedback post for an official solution, there are a couple of quick steps we can take to publish with pnpm.

Firstly, we will need to tell the Cloudflare Pages build agent to use a more up-to-date version of node. At time of writing the default is 12.x, but we can instruct the agent to use a version that will allow us to install and run pnpm. This is achieved by adding an environment variable in the Cloudflare Pages settings with the desired version.


Lastly, in the build command configuration for the page, we need to add a one-liner that will install pnpm and then use pnpm to build our project.

npm install -g pnpm && pnpm i && pnpm build

Double check the build output and root directories are correct for your project and there we go, Cloudflare Pages with pnpm!