首页 前端知识 在powershell中升级pnpm: Unable to find the global bin directory

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

2024-05-19 09:05:36 前端知识 前端哥 46 16 我要收藏

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

  • 简述
  • 错误: Unable to find the global bin directory
  • 解决方法
    • 1. 设置PNPM_HOME
    • 2. 追加PATH
    • 3. 升级

简述

  • 环境: 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
转载请注明出处或者链接地址:https://www.qianduange.cn//article/8897.html
标签
windows
评论
会员中心 联系我 留言建议 回顶部
复制成功!