Deploying On Netlify Using PNPM

netlify logo pnpm logo

After changing this website to pnpm I noticed netlify don't seem to officially support it.

There are a few issue tickets relating to this & the general idea seems to be to disable npm install then run pnpm install to install dependencies on a prebuild script.

  • Disable npm with NPM_FLAGS = "--prefix=/dev/null"
  • Run pnpm install pre build

There seem to be a few ways to implement this

  • create netlify plugin
  • add prebuild script to package.json
  • add pnpm i on build/prebuild with ci check in package.json
  • add pnpm i on build section of netlify.toml

I thought the easiest & cleanest way was to add pnpm i to netlify.toml.

  NPM_FLAGS = "--prefix=/dev/null"
  publish = "public"
  command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"


You will probably want to tell netlify to clear the cache before building if switching from npm or yarn.

The source for the site is available on github.