惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
The Cloudflare Blog
G
Google Developers Blog
博客园_首页
Martin Fowler
Martin Fowler
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
D
Docker
C
Check Point Blog
T
Tailwind CSS Blog
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
GbyAI
GbyAI

博客园 - egreen

在Visual Studio里用原版Copilot交互,烧DeepSeek等国模的Token,让微软和深度求索都为你打工 macOS 上通过二进制安装 Qdrant 并配置为 launchd 服务 CLI-Anything + Gear 最佳实践与踩坑修复沉淀 cli-proxy-api 工业AI报警插件 ZL.Simulator 工业级多仪器仿真与合成数据平台 SyncBus:让多台设备“齐舞”,告别协同烦恼 ZL.ParamEditor:把WinForms配置从‘苦力活’变成‘享受’! 彻底告别 WinForms SOP 开发的“老大难”! 告别“屎山”代码!Gear.NET:专为 .NET 工业自动化打造的微编排框架 electron 安装失败 【MacOS】彻底卸载Navicat dotnet项目编译运行 macOS 彻底卸载和重装 Node.js 指南 Serena 最佳实践方案 Create Custom Endpoint in Directus directus 的endpoint功能 CAN通讯上位机开发快问快答与最佳实践 在老项目中Claude code 中使用 ccpm功能 个人注册企业微信及机器人
pnpm 安装后无法使用
egreen · 2025-09-28 · via 博客园 - egreen

这个问题很常见,是因为 pnpm 的全局安装路径没有包含在系统的 PATH 环境变量中。

🔍 问题原因

当你使用 npm i -g pnpm 安装时,pnpm 被安装到了 npm 的全局目录,但这个目录可能不在你的 PATH 中。

🛠️ 解决方案

方案1:找到并配置 PATH(推荐)

  1. 找到 npm 的全局安装路径:

    这会返回一个路径,通常是 /usr/local 或 /Users/你的用户名/.npm-global

  2. 将路径添加到 PATH:

    • 如果你使用的是 zsh(macOS 默认):

      echo 'export PATH="'$(npm config get prefix)'/bin:$PATH"' >> ~/.zshrc
      source ~/.zshrc
    • 如果你使用的是 bash:

      echo 'export PATH="'$(npm config get prefix)'/bin:$PATH"' >> ~/.bash_profile
      source ~/.bash_profile
  3. 验证是否生效:

方案2:使用 nvm 管理 Node.js(一劳永逸)

如果你经常遇到这类问题,建议使用 nvm:

  1. 安装 nvm:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  2. 重新打开终端,安装 Node.js:

    nvm install --lts
    nvm use --lts
  3. 重新安装 pnpm:

方案3:直接使用完整路径

临时解决方案,使用完整路径运行 pnpm: