How to use corepack?

I use corepack with pnpm, which allows me not to worry about installing / updating versions, and using engines for that:
“engines”: {
“node”: “20.5”,
“pnpm”: “8.6.10”

But corepack doesn’t seem to work, as I simply get an error that pnpm version is mismatched…

Hi there,

Try adding npm install -g pnpm to the start of build command to update pnpm. If you need a specific version, you can do npm install -g pnpm@<version>.

If you already have several commands to build your application, add a to your app containing something like:

npm install -g pnpm
pnpm install
pnpm build

Then add ./ as your build command.


Render Support, UTC+10 :australia:

I’ve actually managed to find a better way to do it, as I have tried both a script and using nom to install pnpm. The issue was that static sites have automatic installation of dependencies, so I couldn’t even get to the build command without a failure due to the engine settings.

So I first had to set SKIP_INSTALL_DEPS to true to disable automatic installation. After that what I originally wanted to do - use corepack, worked without issue. I just had to then set this in the build command: corepack enable; pnpm install; pnpm build;

My suggestion is to make it more obvious int he documentation about the automatic installation of dependencies, as it took me quite a bit of time before I stumbled on that option

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.