pwsh中升级pnpm: Unable to find the global bin directory

简述错误: Unable to find the global bin directory解决方法1. 设置PNPM_HOME2. 追加PATH3. 升级

简述

环境: powershell需求:升级pnpm当前版本:8.15.2目标版本:8.15.3

错误: Unable to find the global bin directory

> pnpm install -g @pnpm/exe

 ERR_PNPM_NO_GLOBAL_BIN_DIR  Unable to find the global bin directory

Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.

解决方法

1. 设置PNPM_HOME

先执行 pnpm setup 找到目录

> pnpm setup

Copying pnpm CLI from C:\Users\fangy\scoop\apps\pnpm\current\pnpm.exe to C:\Users\fangy\AppData\Local\pnpm\pnpm.exe

No changes to the environment were made. Everything is already up to date.

在C:\Users\fangy\AppData\Local\pnpm\

设置环境变量

$env:PNPM_HOME="C:\Users\fangy\AppData\Local\pnpm\"

此时再次运行更新命令,有新的错误,提示设置PATH

> pnpm install -g @pnpm/exe

 ERROR  The configured global bin directory "C:\Users\fangy\AppData\Local\pnpm\" is not in PATH

2. 追加PATH

+=符号直接追加

> $env:PATH+=$env:PNPM_HOME

3. 升级

> pnpm install -g @pnpm/exe

Packages: +2

++

Progress: resolved 6, reused 0, downloaded 2, added 2, done

Downloading registry.npmjs.org/@pnpm/win-x64/8.15.4: 19.94 MB/19.94 MB, done

.pnpm/@pnpm+exe@8.15.4/node_modules/@pnpm/exe: Running preinstall script, done in 136ms

 WARN  The target bin directory already contains an exe called pnpm, so removing C:\Users\fangy\AppData\Local\pnpm\pnpm.EXE

推荐链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: