Skip to content

Instantly share code, notes, and snippets.

@tno2007
Last active November 21, 2023 12:43
Show Gist options
  • Save tno2007/b1df935f2852352de7bb29521183b0f1 to your computer and use it in GitHub Desktop.
Save tno2007/b1df935f2852352de7bb29521183b0f1 to your computer and use it in GitHub Desktop.
uninstall (broken) pnpm installation - via Powershell
# remove via choco if used
choco uninstall pnpm
$chocolatey_install = [Environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine')
rm $chocolatey_install\bin\pnpm* -Recurse -Force
rm $chocolatey_install\bin\pnpx* -Recurse -Force
# remove home folder
$pnpm_home = [Environment]::GetEnvironmentVariable('PNPM_HOME', 'User')
rm $pnpm_home -Recurse -Force
# remove misc folders
$local_app_data = [Environment]::GetFolderPath([Environment+SpecialFolder]::LocalApplicationData)
rm $local_app_data\pnpm* -Recurse -Force
# remove from from path env
## get string to remove
$valueToRemove = [System.Environment]::GetEnvironmentVariable('PNPM_HOME','User')
## get current path
$currentPath = [System.Environment]::GetEnvironmentVariable('PATH','User')
## remove value from path and store in a var
$newPath = ($currentPath.Split(';') | Where-Object { $_ -ne $valueToRemove }) -join ';'
## set new path using the var
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
# Remove env var
[Environment]::SetEnvironmentVariable('PNPM_HOME','', 'User')
# now use node v16 and up and enable corepack :-)
corepack enable
# be happy :-)
pnpm -v
# upgrade to latest
## first check what version is the latest
npm show pnpm version
## perform update
corepack prepare pnpm@<version> --activate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment