Installing pnpm on macOS with npm (Not Homebrew)
When working with Node.js on macOS, many developers default to
installing tools like pnpm via Homebrew. While convenient, this
approach ties pnpm to your system rather than your Node.js
environment. If you're using a Node version manager such as fnm (Fast
Node Manager), it's better to install pnpm via npm so that it is
scoped to the Node.js version instead of being installed globally on
your machine.
Why not use Homebrew for pnpm?
Homebrew installs pnpm system-wide, which means: - It doesn't respect
the Node.js version you're using. - You may run into mismatched
environments when switching Node versions. - Updates are tied to
Homebrew rather than your Node manager.
The better way: Install pnpm via npm
Since fnm manages Node.js versions per project or per shell,
installing pnpm through npm ensures it is version-scoped. Here's
how:
# Ensure you’re using fnm and have a Node.js version set
fnm use --install-if-missing 18
# Install pnpm using npm (tied to this Node.js version)
npm install -g pnpmNow, whenever you switch Node.js versions with fnm, you can install
the corresponding pnpm for that version if needed. This keeps your
setup isolated and avoids conflicts.
Verifying the installation
Check that pnpm is installed and tied to your Node.js version:
pnpm -v
node -vBoth should work seamlessly under the version controlled by fnm.
✅ With this setup, pnpm is not a global system binary from
Homebrew---it's scoped and version-aware, perfectly aligned with how
fnm manages Node.