DEV Community

kay-adamof
kay-adamof

Posted on

How to upgrade `pnpm`

I have summarized the procedure for upgrading the version of pnpm, which is a package manager for Node.

While updating the version of pnpm is not something you do frequently, when you do need to update it, you may wonder, "What should I do?" and it can take several minutes to several tens of minutes.

There are several installation routes for pnpm, and the method of version upgrade varies depending on which one you chose.

Here, I have only listed the procedures that I thought could be used generically (not limited to pnpm).
If you want to know other methods, please refer to the following GitHub Discussions.

Confusing about how to update pnpm itself

Steps to upgrade pnpm

  • Check the installation directory with the command:
   where pnpm
Enter fullscreen mode Exit fullscreen mode
  • Delete the installation directory with the command:
   rm -rf installation_directory
Enter fullscreen mode Exit fullscreen mode
  • Reinstall pnpm using the command:
   curl -fsSL https://get.pnpm.io/install.sh | sh -
Enter fullscreen mode Exit fullscreen mode

Official pnpm installation method

Actual Commands

$ where pnpm
/usr/local/bin/pnpm
/usr/local/bin/pnpm


$ rm -rf /usr/local/bin/pnpm


$ where pnpm
pnpm not found


$ curl -fsSL https://get.pnpm.io/install.sh | sh -
==> Downloading pnpm binaries 8.6.11
 WARN  using --force I sure hope you know what you are doing
Appended new lines to /Users/YOU/.zshrc

Next configuration changes were made:
export PNPM_HOME="/Users/YOU/Library/pnpm"
case ":$PATH:" in
  *":$PNPM_HOME:"*) ;;
  *) export PATH="$PNPM_HOME:$PATH" ;;
esac

To start using pnpm, run:
source /Users/YOU/.zshrc


$ source /Users/YOU/.zshrc

$ pnpm -v
8.6.11
Enter fullscreen mode Exit fullscreen mode

In my case, the steps above allowed me to use pnpm without any issues. However, please be cautious as this method involves deleting the entire executable directory.

That's all!

Top comments (0)