corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'Short answer
corepack enable writes small link files for yarn and pnpm next to your node binary. If that folder, often /usr/local/bin, is not writable by your user, the command stops with EACCES. Point it at a folder you own with --install-directory, or run it once as an admin. A read-only file system also makes it fail.
Fix it fast
1Find out which cause you have
Find out which folder corepack wants to write to and whether your user may write there.
which node ls -ld "$(dirname "$(which node)")"2Match what you see, then jump to its fix
What does the error look like?
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
Cause 1 of 2
The folder that holds node is owned by root
1Check
The README says corepack enable installs the yarn and pnpm shims on your path. It puts them where Node.js is installed, so a root-owned folder blocks a normal user. The check above shows the owner and mode.
ls -ld /usr/local/bin2Fix
Create a folder you own, put it on your PATH, and tell corepack to place the shims there with --install-directory.
mkdir -p ~/.local/bin
corepack enable --install-directory ~/.local/bin
# make sure this line is in ~/.zshrc or ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"3Verify
Open a new shell and ask for the package manager version.
which pnpm
pnpm --versionConfirmed by github.com
Cause 2 of 2
The file system holding corepack is read-only
1Check
The README warns that corepack enable fails when the file system holding the corepack binary is read-only.
mount | grep -E " on (/|/usr) "2Fix
Use --install-directory with a folder on a writable file system, as in the first cause. As the README suggests, a shell alias that calls corepack is another way when nothing on the system path can be written.
mkdir -p "$HOME/.local/bin"
corepack enable --install-directory "$HOME/.local/bin"3Verify
The shim exists and points to corepack.
ls -l ~/.local/bin/pnpmConfirmed by github.com
How do I stop it coming back?
- Prefer a Node.js install that your own user owns (a version manager such as nvm), so global tools never need root.
- Keep one folder of your own on PATH for command shims.
- Record the package manager in the packageManager field so everyone gets the same version.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
firebase deploy stops because the predeploy lint step failed
Error: There was an error deploying functions
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy.
3 causes, each with a fixBack end
fluent-ffmpeg cannot find the ffmpeg or ffprobe binary
Error: Cannot find ffprobe
fluent-ffmpeg does not bundle ffmpeg.
4 causes, each with a fixBack end
The http-server command does not run after installing it
http-server: command not found
http-server is a command-line package, so it must be installed globally or run through npx.
3 causes, each with a fix