#Using `pnpm` version 9 fails when trying to build application (Deployment)

10 messages · Page 1 of 1 (latest)

past tartan
#

Hi, recently my Amplify builds stopped working, it started to fail out of nowhere in my previews. I'm using pnpm. And the first time it failed I got the following error on preBuild:

2024-07-23T06:30:20.749Z [WARNING]: ! Unable to write cache: TAR_BAD_ARCHIVE: Unrecognized archive format)}

After that, the following builds starting failing with errors like:

ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "ampx" not found

So, I tried using npx, which worked, but then I got the same error with tsx, then vite... So basically, I can't seem to use the packages anymore. After some digging, I figured out Amplify was now using a different version of pnpm, so I was able to fix the issue by letting corepack know to use version 8 of pnpm (corepack use pnpm@8), instead of version 9.

I'm still not sure why version 9 is giving me that error, but downgrading is what worked for me. However, I'm creating this issue to both help anyone with this problem, and to start a conversation on how this issue could be solved.

I updated locally everything to pnpm@9 and while locally everything seemed right, there may be something else missing to make it work in CI (Amplify Build).

fleet frigate
#

👋 v9 of pnpm has a new/modified lockfile format (and this new categories feature)

#

I would recommend using corepack use pnpm@8 locally to add a packageManager entry to your package.json and adding corepack enable in your buildspec to resolve to the version specified in your package.json

#

though that error is not one I'd expect from an install with a frozen lockfile

past tartan
#

Agree, it's an odd error, and I'm sure there's some configuration specific to CI environments that I may be missing, similar to the node-linker=hoisted needed for mono-repos.

fleet frigate
#

just reread your message and noticed you mentioned you're on 9 locally and it's fine 🤔

true flicker
#

@past tartan did you happen to figure this out? did you just end up pinning to v8? running into the same thing trying to wire up github actions + pnpm + amplify backend

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Node Installation
        uses: actions/setup-node@v4
        with:
          node-version: latest

      - name: Install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: latest
          run_install: |
            - args: [--frozen-lockfile]

      - name: Deploy with Amplify
        run:
          pnpm exec ampx pipeline-deploy --branch ${{ env.BRANCH_NAME }} --app-id
          ${{env.AMPLIFY_APP_ID}}
fleet frigate
past tartan