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.
Two installation paths matter on Ubuntu: the standalone installer for the simplest cross-version setup, and Corepack when you want pnpm pinned per project through the packageManager field in package.json. 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 the practical choices are the official installer or a Corepack workflow. Compare them first:
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Standalone Script (Recommended) | Official install script | Latest stable release | Manual with pnpm self-update | Most Ubuntu users, including systems without Node.js yet |
| Corepack | Corepack workflow | Project-pinned stable release | Manual with corepack use pnpm@latest-10 | Teams pinning pnpm inside each repository |
For most Ubuntu setups, use the standalone script. It behaves the same on Ubuntu 26.04, 24.04, and 22.04, and it does not require Node.js first. Corepack is the better fit when your project already uses a current Node.js release and you want pnpm versioned inside package.json.
These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. The standalone installer works on all three releases. Corepack works cleanly with Ubuntu 26.04’s default Node.js packages, while Ubuntu 24.04 and 22.04 are usually better served by the standalone method unless you install a newer Node.js release first.
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:
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.32.0
The standalone installer always downloads the current pnpm 10 release, 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-corepackin the default repositories, so this method is straightforward there. Ubuntu 24.04 and 22.04 do not ship that package, and the latestcorepack@latestrelease targets newer Node.js lines than the default Ubuntu packages. On those older releases, use the standalone pnpm installer above or install a newer Node.js release first with our Node.js on Ubuntu guide.
Install Node.js, npm, and the distro Corepack package on Ubuntu 26.04:
sudo apt install -y nodejs npm node-corepack
Create or enter a project directory that already has a package.json. For a fresh test project, initialize one with npm:
mkdir ~/pnpm-corepack-demo && cd ~/pnpm-corepack-demo
npm init -y
Enable the pnpm shim and pin the latest pnpm 10 release to the project:
sudo corepack enable pnpm
corepack use pnpm@latest-10
Installing pnpm@10.32.0 in the project... Already up to date Done in 861ms using pnpm v10.32.0
Confirm the shim is active:
pnpm --version
10.32.0
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.
Install and Add Dependencies with pnpm on Ubuntu
Use pnpm add when you are introducing a new dependency, and use pnpm install when the repository already has a package.json or pnpm-lock.yaml that you want to sync locally:
pnpm add lodash
pnpm install
Progress: resolved 1, reused 0, downloaded 0, added 0 Packages: +1 + Progress: resolved 1, reused 0, downloaded 1, added 1, done dependencies: + lodash 4.17.23 Done in 1.1s using pnpm v10.32.0
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 build form when the script name does not conflict with a built-in pnpm command:
pnpm run 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.
Use pnpm dlx on Ubuntu for One-Off Tools
pnpm dlx downloads a package, runs it once, and leaves your global install untouched. That makes it useful for scaffolders, diagnostics, and one-off commands:
pnpm dlx cowsay@1.6.0 "pnpm ready"
____________
< pnpm ready >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
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.
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
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
Nothing to stop. No server is running for the store at /home/linuxcapable/.pnpm-store/v10 The currently active pnpm v10.32.0 is already "latest" and doesn't need an update
If pnpm reports that a newer release is available, the same command upgrades the standalone binary in place. The username portion of the store path will match your own account.
Update Corepack-Managed pnpm on Ubuntu
For Corepack workflows, refresh the version pinned inside the project:
corepack use pnpm@latest-10
Installing pnpm@10.32.0 in the project... Already up to date Done in 861ms using pnpm v10.32.0
This 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
Your current shell has not loaded the new PNPM_HOME block yet. Reload the shell configuration and clear any cached command lookups:
source ~/.bashrc
hash -r
Verify that pnpm is now available:
pnpm --version
10.32.0
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 still install the latest Corepack with an engine warning, but Ubuntu 26.04’s Node.js 22 packages are the cleaner fit for Corepack.
curl -fsSL https://get.pnpm.io/install.sh | sh -
source ~/.bashrc
pnpm --version
10.32.0
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)"
rm -rf "$PNPM_HOME" "$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, 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 -y node-corepack
sudo apt autoremove -y
Verify that the pnpm shim is gone:
pnpm --version
bash: pnpm: command not found
pnpm on Ubuntu FAQ
No. Ubuntu 26.04, 24.04, and 22.04 do not provide a pnpm package in the default repositories, so the practical options are the official install script or a Corepack workflow.
Yes. The official standalone installer from pnpm.io downloads a self-contained pnpm binary, so you can install pnpm before Node.js is present.
Use pnpm when you want a shared content-addressable store, stricter dependency handling, and stronger workspace tooling. Keep npm when you only need the default package manager that ships with Node.js or you work in environments already standardized on npm.
Only after you solve the Node.js version gap. Ubuntu 24.04’s default Node.js 18 packages can install the latest Corepack with an engine warning, and Ubuntu 22.04’s default Node.js 12 packages are too old to run current Corepack. On those releases, the standalone pnpm installer is usually the simpler path unless you already upgraded Node.js.
Choose pnpm when disk efficiency and strict dependency resolution matter more than matching a Yarn-based workflow. Choose Yarn when the repository already depends on Yarn-specific features or team conventions. If you need both package managers on the same machine, keep them project-scoped rather than mixing lockfiles inside one project.
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:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>