From 9e13593d221b882526ae88de3c390b42a73e2c07 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 20 Oct 2022 21:12:40 -0500 Subject: [PATCH] Add Pin Specific pnpm Version For Builds as a Vercel TIL --- README.md | 3 +- .../pin-specific-pnpm-version-for-builds.md | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 vercel/pin-specific-pnpm-version-for-builds.md diff --git a/README.md b/README.md index ee4ad7e..e78969c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1257 TILs and counting..._ +_1258 TILs and counting..._ --- @@ -1286,6 +1286,7 @@ _1257 TILs and counting..._ - [Add Web Server Layer Redirects](vercel/add-web-server-layer-redirects.md) - [Deploy An App Without Pushing An Empty Commit](vercel/deploy-an-app-without-pushing-an-empty-commit.md) - [Naming Of The Vercel Config File](vercel/naming-of-the-vercel-config-file.md) +- [Pin Specific pnpm Version For Builds](vercel/pin-specific-pnpm-version-for-builds.md) - [Share Development Environment Variables Via CLI](vercel/share-development-environment-variables-via-cli.md) ### Vim diff --git a/vercel/pin-specific-pnpm-version-for-builds.md b/vercel/pin-specific-pnpm-version-for-builds.md new file mode 100644 index 0000000..adbd58a --- /dev/null +++ b/vercel/pin-specific-pnpm-version-for-builds.md @@ -0,0 +1,35 @@ +# Pin Specific pnpm Version For Builds + +Vercel recognizes when [a project contain a `pnpm-lock.yaml` +file](https://vercel.com/changelog/projects-using-pnpm-can-now-be-deployed-with-zero-configuration) +and will automatically use [`pnpm`](https://pnpm.io/) for builds of that +project. + +It looks for [the `lockfileVersion` in `pnpm-lock.yaml` to determine what major +version of `pnpm` to +install](https://vercel.com/docs/concepts/deployments/configure-a-build#install-command). +If the `lockfileVersion` is `5.4`, then it will use the latest pnpm v7. +Otherwise it will fallback to the latest pnpm v6. + +That's the extent of the control you have over the `pnpm` version. That is, +unless you are to use [this experimental corepack +feature](https://vercel.com/docs/concepts/deployments/configure-a-build#corepack). +Set the `ENABLE_EXPERIMENTAL_COREPACK` environment variable to `1` in your +project's _Environment Variables_ under _Settings_. + +Then specify the `pnpm` version with the `packageManager` key in your +`package.json`. + +```json +{ + "packageManager": "pnpm@7.13.2" +} +``` + +Even though the current latest is `7.13.5`, Vercel will see the Corepack +environment variables and the `packageManager` version and use `7.13.2` +instead. + +See [this PR](https://github.com/skillrecordings/products/pull/535) and [this +issue](https://github.com/prisma/prisma/issues/12921#issuecomment-1284425847) +for more details.