Skip to content
Latchkey

corepack enable "EACCES permission denied" - Fix Shim Install in CI

corepack enable writes yarn/pnpm shims into Node’s install bin directory. If that directory is root-owned and the build runs as non-root, the symlink creation fails with EACCES.

What this error means

corepack enable errors with EACCES while creating shims in a Node bin path. It is common in Docker images where Node is installed as root but the build user is non-root.

Corepack output
Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js'
'/usr/local/bin/pnpm'

Common causes

The Node bin directory is owned by root

Corepack tries to symlink shims into e.g. /usr/local/bin, which the non-root build user cannot modify.

corepack enable run without sufficient privilege

In CI the step runs as the build user; without ownership or a writable install dir, shim creation is denied.

How to fix it

Enable Corepack with the right privilege or target

Either run enable as root in the image build, or point shims at a user-writable dir.

Dockerfile / Terminal
# in a Dockerfile, while still root:
RUN corepack enable

# or as non-root, install shims to a writable dir:
corepack enable --install-directory "$HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"

Fix ownership of the bin path

  1. In images, run corepack enable during the root-privileged build phase.
  2. For ad hoc CI, use --install-directory pointing at a user-owned PATH entry.
  3. Avoid sudo for per-run enabling; bake it into the image instead.

How to prevent it

  • Enable Corepack at image-build time as root.
  • Use a user-writable install directory for non-root runs.
  • Keep package-manager provisioning in the image, not per-job.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →