[ERR_PNPM_UNEXPECTED_STORE] Unexpected store location when adding pnpm packages to Task Runners

Hi everyone,

I recently faced this issue and managed to solve it. I wanted to post my findings here in case this isn’t intended behavior, or in case it helps someone else.

The Issue

After the latest “beta” version [2.29.5] of the task runners, I started getting this error when trying to build a custom runner image:

#13 [stage-1 7/8] RUN cd /opt/runners/task-runner-javascript &&     pnpm add     moment     uuid
#13 0.829 ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.10.0.tgz
#13 2.407 [ERR_PNPM_UNEXPECTED_STORE] Unexpected store location
#13 2.407 
#13 2.407 The dependencies at "/opt/runners/task-runner-javascript/node_modules" are currently linked from the store at "/root/.local/share/pnpm/store/v10".
#13 2.407 
#13 2.407 pnpm now wants to use the store at "/root/.local/share/pnpm/store/v11" to link dependencies.
#13 2.407 
#13 2.407 If you want to use the new store location, reinstall your dependencies with "pnpm install".
#13 2.407 
#13 2.407 You may change the global store location by running "pnpm config set store-dir <dir> --global".
#13 2.407 (This error may happen if the node_modules was installed with a different major version of pnpm)
#13 ERROR: process "/bin/sh -c cd /opt/runners/task-runner-javascript &&     pnpm add     moment     uuid" did not complete successfully: exit code: 1

The Symptoms

  1. The Store Error: When running a standard pnpm add command in my custom Dockerfile, I got [ERR_PNPM_UNEXPECTED_STORE]. The base image’s node_modules were linked to a v10 store, but my build step was trying to use a v11 store.
  2. The npx Error: I tried forcing pnpm v10 using npx -y pnpm@10 add ..., but the base image is built on python:alpine and only copies the node binary and corepack. It doesn’t include npm or npx, resulting in /bin/sh: npx: not found.

The Root Cause

Looking at n8n’s source code, they recently updated the runner Dockerfiles to explicitly pin PNPM_VERSION=10.32.1 during their build process (Commit 25d0d12).

They did this because pnpm deploy drops the packageManager field, so a bare corepack enable pnpm resolves to pnpm 11.x. pnpm 11 defaults minimumReleaseAge to 24 hours, which rejects dependencies published less than a day ago.

However, if you just run a bare pnpm add in your custom Dockerfile, corepack ignores this pinned version and automatically downloads the newest version (v11). pnpm 11 uses a different store format and refuses to interact with the v10 store left behind by the base image.

The Solution

To fix this, you have to use corepack to explicitly activate pnpm v10 before running your pnpm add command.

Instead of doing this:

RUN cd /opt/runners/task-runner-javascript && \
    pnpm add moment uuid

Change your Dockerfile step to this:

# Activate pnpm 10.32.1 to match the base image's v10 store (npx is not available in this image)
RUN corepack prepare pnpm@10.32.1 --activate && \
    cd /opt/runners/task-runner-javascript && \
    pnpm add \
    moment \
    uuid

Hope this saves someone else a few hours of debugging! I’d also appreciate it if someone could confirm whether pinning to v10 is the expected behavior moving forward.

Great share, @mohamed3nan !!

Thanks for this, I have created CAT-3666 as the internal dev ticket to get this fixed.

Thanks for finding that fix @mohamed3nan . it saved me a lot of investigation!. It is a little fragile if they change the version so I have updated it to explicitly read the current version like so:

RUN PNPM_VER=$(sed -n 's/.*"packageManager": "pnpm@\([^"]*\)".*/\1/p' /opt/runners/task-runner-javascript/node_modules/.modules.yaml) && \
    corepack prepare pnpm@${PNPM_VER} --activate && \
    cd /opt/runners/task-runner-javascript && \
    pnpm add \
        <list-of-packages>

Hopefully there will be a proper fix before the version changes but better to be safe.