JavaScript projects waste a surprising amount of time and disk space when every repository downloads its own copy of the same dependencies. pnpm fixes that with a content-addressable store, stricter dependency handling, and workspace tools that scale better than a pile of duplicated node_modules directories. If you need to install pnpm on Ubuntu, the cleanest starting point is the official standalone installer because it works on Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS without waiting for a distro package.
Most Ubuntu users only need the standalone installer. Corepack is useful when a project should pin its package manager through the packageManager field in package.json, but it depends more heavily on the Node.js version underneath it. From there, you can move into everyday pnpm commands, configuration, workspace filtering, updates, troubleshooting, and clean removal without switching tools.
Install pnpm on Ubuntu
Ubuntu 26.04, 24.04, and 22.04 do not provide a pnpm package in the default APT repositories, so sudo apt install pnpm will not give you the pnpm CLI. APT manages Ubuntu system packages, while pnpm manages JavaScript dependencies from npm-compatible registries. The practical choices are the official installer or a Corepack workflow:
| Method | Source | Channel | Updates | Best Fit |
|---|---|---|---|---|
| Standalone script | Official install script | Default latest / latest-10 track | pnpm self-update | Most Ubuntu desktop, server, and WSL installs, including systems without Node.js yet |
| Corepack | Corepack workflow | Project-pinned latest-10 track | corepack use pnpm@latest-10 | Teams that already manage a current Node.js stack and want pnpm pinned per repository |
For most Ubuntu setups, use the standalone script. It behaves the same on Ubuntu 26.04, 24.04, and 22.04, and after curl and CA certificates are present, the pnpm install itself runs in your user account without sudo. Corepack is the better fit when your project already uses a current Node.js release and you want pnpm versioned inside package.json.
The official pnpm docs also show npm-based installs, including npm install -g pnpm@latest-10. Keep that path for systems where you already manage a supported Node.js release and a deliberate npm global prefix. pnpm does not use Ubuntu-style LTS labels for the CLI; use official dist-tags such as latest-10, latest-11, and next-11 when you need a release line. Node-dependent pnpm 11 installs require Node.js 22 or newer, so the pnpm 10 track remains the low-friction default for this Ubuntu workflow.
Standalone, Corepack, and npm-global installs can coexist, but your shell runs whichever pnpm appears first on PATH. If you mix methods later, check the active binary with command -v pnpm before troubleshooting version or command-not-found issues.
These same terminal commands also work on Ubuntu under WSL. For GitHub-hosted Ubuntu runners, do not assume pnpm is already present just because Node.js is cached on the runner image; add a pnpm setup step to the workflow or use the official pnpm continuous integration docs.
Update Ubuntu and Install curl for pnpm
Ubuntu desktop installs often already include curl, but server and minimal images may not. Refresh APT metadata and install curl plus CA certificates before you run the official install script:
sudo apt update && sudo apt install -y curl ca-certificates
These commands use
sudowhen they need root privileges. If your account is not in the sudoers file yet, follow our guide on how to add a new user to sudoers on Ubuntu before continuing.
Install pnpm on Ubuntu with the Standalone Script
The official pnpm installer is the simplest Ubuntu method because it downloads a self-contained pnpm binary and adds the required PNPM_HOME block to your shell configuration. Run it as your normal user, not with sudo:
curl -fsSL https://get.pnpm.io/install.sh | sh -
Load the new shell configuration into the current terminal so the pnpm command is immediately available:
source ~/.bashrc
If you use Zsh instead of Bash, reload ~/.zshrc rather than ~/.bashrc.
Verify that pnpm is on your path:
pnpm --version
10.x.x
The standalone installer follows pnpm’s default release track, so the patch version in your terminal may be newer than the example shown here.
Install pnpm on Ubuntu with Corepack
Corepack makes sense when the repository itself should declare which pnpm release it expects. On Ubuntu, the pnpm shims live under system-owned paths, so enabling them needs sudo.
Ubuntu 26.04 ships
node-corepackand Node.js 22 in the Universe repository, so this method is straightforward there. Ubuntu 24.04 and 22.04 do not shipnode-corepack; use the standalone pnpm installer or install a newer Node.js release first with our Node.js on Ubuntu guide.
If APT cannot locate node-corepack on Ubuntu 26.04, enable the Universe component first with the Ubuntu Universe repository guide. Then install Node.js and Corepack:
sudo apt install -y nodejs node-corepack
Create or enter a project directory that already has a package.json. For a fresh test project, write a minimal package file without pulling in npm:
mkdir ~/pnpm-corepack-demo && cd ~/pnpm-corepack-demo
printf '%s\n' '{"name":"pnpm-corepack-demo","version":"1.0.0"}' > package.json
Enable the pnpm shim and pin the latest pnpm 10 release to the project:
sudo corepack enable pnpm
corepack use pnpm@latest-10
Corepack prints an install or already-current message and updates the local project metadata. Confirm the pinned pnpm shim is active:
pnpm --version
10.x.x
Corepack also writes a packageManager field into package.json, which keeps the project on the same pnpm release when other developers clone it.
Use pnpm on Ubuntu
Once pnpm is installed, the commands most people reach for first are pnpm add, pnpm install, pnpm run, and pnpm dlx. The pnpm CLI reference covers the full command set, but these are the ones worth keeping close. Use pnpm when disk efficiency, stricter dependency resolution, and workspace filters matter; keep npm or Yarn when a repository already standardizes on those lockfiles.
Install and Add Dependencies with pnpm on Ubuntu
Use pnpm add when you are introducing a new dependency:
pnpm add lodash
Packages: +1 + dependencies: + lodash 4.x.x Done in 1.1s using pnpm v10.x.x
Use pnpm install when the repository already has a package.json or pnpm-lock.yaml that you want to sync locally:
pnpm install
Run Scripts with pnpm on Ubuntu
The pnpm scripts documentation covers lifecycle hooks and script behavior in depth. For day-to-day work, use the explicit form pnpm run dev or the shorter pnpm dev and pnpm build forms when the script name does not conflict with a built-in pnpm command:
pnpm run dev
pnpm dev
pnpm build
The shorthand form is handy in CI jobs and local development because it saves a few keystrokes without changing how the script is resolved. If a script name ever conflicts with a pnpm built-in command, use pnpm run script-name so the intent is unambiguous.
Use pnpm dlx on Ubuntu for One-Off Tools
pnpm dlx is pnpm’s npx-style command. It downloads a package, runs it once, and leaves your global install untouched, which makes it useful for scaffolders, diagnostics, and one-off commands:
pnpm dlx create-vite@latest --help
The command prints the scaffold tool’s help text without installing create-vite globally.
Configure pnpm on Ubuntu
The pnpm configuration docs use the same .npmrc model that npm uses, so pnpm config is the fastest way to write settings without editing those files by hand.
Set a Custom pnpm Store Directory on Ubuntu
If you want the shared pnpm store on a larger disk, a bind mount, or a dedicated development volume, set the store path explicitly:
pnpm config set store-dir ~/.pnpm-store
pnpm config get store-dir
/home/linuxcapable/.pnpm-store
The username portion of the path will match your own account. If you want to see the active store path with pnpm’s versioned subdirectory, run pnpm store path.
Handle pnpm Certificate Errors on Ubuntu
Ubuntu’s ca-certificates package is enough for public registries in normal setups. If your company or private registry uses a private certificate authority, keep strict-ssl enabled and point pnpm to the PEM certificate file with the official cafile setting:
install -D -m 0644 ~/Downloads/company-ca.pem ~/.config/pnpm/company-ca.pem
pnpm config set cafile ~/.config/pnpm/company-ca.pem
pnpm config get cafile
/home/linuxcapable/.config/pnpm/company-ca.pem
Use pnpm Workspace Filters on Ubuntu
When a repository contains multiple packages, the pnpm filtering syntax lets you run commands for one package, its dependencies, or its dependents without traversing the whole workspace.
Run pnpm –filter Commands on Ubuntu Workspaces
These three patterns cover most monorepo work:
pnpm --filter @demo/web build
pnpm --filter @demo/web... build
pnpm --filter "...@demo/api" build
@demo/webruns the command only inside@demo/web.@demo/web...includes@demo/weband the packages it depends on....@demo/apiincludes@demo/apiand packages that depend on it.
Example output from pnpm --filter @demo/web... build looks like this:
Scope: all 2 workspace projects packages/api build$ echo building api packages/api build: building api packages/api build: Done packages/web build$ echo building web packages/web build: building web packages/web build: Done
Avoid pnpm –filter dlx on Ubuntu
Keep --filter for workspace commands and pnpm dlx for temporary package execution. A command such as pnpm --filter dlx treats dlx as a workspace filter target, not as the pnpm dlx subcommand. Choose the workspace target first, then run a normal script, or use pnpm dlx package-name without a workspace filter.
Update pnpm on Ubuntu
Use the update command that matches the way you installed pnpm. Mixing methods makes later troubleshooting harder.
Update Standalone pnpm on Ubuntu
pnpm self-update
If pnpm is already current, the command reports that the active version does not need an update. If a newer release is available, it upgrades the standalone binary in place.
Update Corepack-Managed pnpm on Ubuntu
For Corepack workflows, refresh the version pinned inside the project:
corepack use pnpm@latest-10
Corepack prints an install or already-current message and updates the local packageManager field so the repository continues to advertise the pnpm release it expects.
Troubleshoot pnpm on Ubuntu
Most pnpm issues on Ubuntu come from shell initialization or trying to force a Corepack workflow onto an older Node.js stack.
Fix “pnpm: command not found” After Installation on Ubuntu
If the standalone installer completes but the next command fails with this message:
bash: pnpm: command not found
Ubuntu may also suggest npm because the npm package exists while pnpm does not. Install pnpm with the standalone or Corepack method instead of running sudo apt install pnpm.
Your current shell has not loaded the new PNPM_HOME block yet. For Bash, reload the shell configuration and clear any cached command lookups:
source ~/.bashrc
hash -r
For Zsh, reload ~/.zshrc and refresh the command hash table:
source ~/.zshrc
rehash
Verify that pnpm is now available:
pnpm --version
10.x.x
Fix “sudo: pnpm: command not found” on Ubuntu
The standalone installer writes PNPM_HOME to your user shell profile, not root’s environment. If pnpm --version works but sudo pnpm --version fails, avoid using sudo for normal project installs and scripts. Use sudo for Ubuntu package-manager commands, and run pnpm as your regular development user.
Fix Corepack Errors on Ubuntu 22.04 and 24.04
Ubuntu 22.04’s default Node.js 12 packages are too old for the current Corepack release, which leads to errors like this:
/usr/local/lib/node_modules/corepack/dist/corepack.js:2
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT??='0';
^
SyntaxError: Unexpected token '?'
Check which Node.js line the system is using before you troubleshoot anything else:
node --version
v12.22.9
If your output is on an older line, switch to the standalone pnpm installer or upgrade Node.js first. Ubuntu 24.04’s default Node.js 18 packages can run pnpm 10, but they do not provide the node-corepack package used in the Corepack install section. Ubuntu 26.04’s Node.js 22 packages are the cleaner distro-package fit for Corepack.
curl -fsSL https://get.pnpm.io/install.sh | sh -
source ~/.bashrc
pnpm --version
10.x.x
If Corepack reports that no pnpm version is set for the project, move into a directory with package.json and run corepack use pnpm@latest-10. That writes the packageManager field Corepack uses on the next command.
Remove pnpm from Ubuntu
Remove the Standalone pnpm Installation from Ubuntu
The next commands permanently delete the standalone pnpm binary under
PNPM_HOMEand the shared package store returned bypnpm store path. Any cached packages will need to be downloaded again the next time you use pnpm.
Capture the current store path before removing pnpm itself:
STORE_DIR="$(pnpm store path)"
PNPM_HOME_DIR="${PNPM_HOME:-$HOME/.local/share/pnpm}"
rm -rf "$PNPM_HOME_DIR" "$STORE_DIR"
Next, open your shell configuration and remove the block between # pnpm and # pnpm end:
nano ~/.bashrc
If your login shell is Zsh, remove the same block from ~/.zshrc and reload that file instead. For Bash, reload the shell and clear cached command paths so the terminal stops pointing at the deleted binary:
source ~/.bashrc
hash -r
Verify removal:
pnpm --version
bash: pnpm: command not found
Remove Corepack-Managed pnpm from Ubuntu
Disable the pnpm shim first:
sudo corepack disable pnpm
If you installed Corepack with npm on Ubuntu 24.04 or 22.04 outside the main Ubuntu 26.04 method, remove that global package too:
sudo npm uninstall --global corepack
Ubuntu 26.04 may still provide corepack through the distro node-corepack package. Remove it only if you no longer want any Corepack-managed package managers on the system:
sudo apt remove node-corepack
Preview leftover dependencies before cleaning anything else:
sudo apt autoremove --dry-run
If the preview only lists packages you no longer need, run the interactive cleanup:
sudo apt autoremove
If you installed nodejs only for this Corepack method and no other project needs it, remove nodejs separately after checking the same preview. Then confirm the distro Corepack package is no longer installed:
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' node-corepack 2>/dev/null | grep '^ii' || echo "node-corepack is not installed"
node-corepack is not installed
Verify that the pnpm shim is gone:
hash -r
pnpm --version
bash: pnpm: command not found
Conclusion
pnpm is installed on Ubuntu and ready for faster dependency installs, lighter disk usage, and cleaner workspace automation. If your projects still need a newer runtime first, follow our guide to install Node.js on Ubuntu next, then install TypeScript on Ubuntu or install Git on Ubuntu to round out the toolchain.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>