15

I'm currently working on an application that uses pnpm 6 but I have pnpm 7 installed. I couldn't find any documentation that shows me how to install and switch between versions. Thank you!

Roskow
  • 320
  • 1
  • 7
Shey Umar
  • 151
  • 1
  • 1
  • 3

5 Answers5

15

If you have installed pnpm through Node.js corepack:

corepack enable

you can just run:

corepack prepare pnpm@7.13.6 --activate

Here is the doc

6

I'm also going with node.js/corepack. I have to jump between versions 6 and 7 for different projects.

With a recent version of node.js (16.17+) it's even easier to switch between the most recent of major versions of pnpm. For the latest of version 7 you'd type:

corepack prepare pnpm@latest --activate

For the latest of version 6:

corepack prepare pnpm@latest-6 --activate

It's also described in the installation doc of pnpm.

Dasch33
  • 91
  • 1
  • 2
  • this script worked well to get the lastest of a specific version! great find! the installation doc doesn' describe it though.. – SetiZ Jun 20 '23 at 13:22
3

There may be a better way but I just uninstalled version 7 and installed version 6. I did this with yarn but you can do it with any method listed in the uninstall/install documentation. Just make sure you uninstall using the method you originally used to install it (npm, yarn, brew, etc.).

This is what I did:

yarn global remove pnpm
yarn global add pnpm@6.32.1 (installed specific latest pnpm version)

Currently, it seems there is no solution similar to nvm. Reference

Roskow
  • 320
  • 1
  • 7
1

In my case, to setup the nextauthjs local environment on Ubuntu 22.04 I did the followings.

serdarsen
  • 193
  • 2
  • 8
0

I installed pnpm with Vite in 2022 or 2023 on Windows.

I did the global installations but 'pnpm -v' always returned the old version:

pnpm i -g pnpm
pnpm i -g @pnpm/exe

pnpm ls -g
// @pnpm/exe 8.5.1
// pnpm 8.5.1

pnpm -v
// 7.25.1

The 'pnpm -v' finally gave me 8.5.1 after running the following commands:

corepack enable
corepack prepare pnpm@8.5.1 --activate