AI Tools Guide

NPM Command Not Found Fix Mistakes

终端报 npm: command not found 或 'npm' 不是内部或外部命令,几乎都是 Node.js 没装好、PATH 没配、或装了 nvm 没激活。给出 macOS/Linux/Windows 的真实检查和修复命令。

What is the problem?

终端报 npm: command not found 或 'npm' 不是内部或外部命令,几乎都是 Node.js 没装好、PATH 没配、或装了 nvm 没激活。给出 macOS/Linux/Windows 的真实检查和修复命令。

Quick solution

Treat this as a Node.js errors troubleshooting issue. First confirm the environment, inputs, permissions, logs, and delivery boundary. Then use the linked deep guide for the full checklist before changing production code or promising a result.

Read the deep guide

Detailed steps

  1. 两个都报 not found → Node 根本没装(见 ①)
  2. `node -v` 有、`npm -v` 没有 → 少见,重装 Node 即可
  3. 刚装完就报 → 多半是 PATH 或终端没重开(见 ②③)
  4. 先**完全关掉终端重新打开**(PATH 改动对已开的终端不生效)——这一步能解决一大半。
  5. 还不行,确认安装目录在 PATH 里:macOS/Linux 看 `echo $PATH`;Windows 在「系统环境变量」里确认有 Node 的路径。
  6. 别随便复制网上"一键修复 PATH"的脚本去改系统环境变量,先看懂它改什么。

Commands or code

node -v
npm -v

Risk notes

Confirm the real project environment, account permissions, platform rules, and output quality before delivery. Do not ship AI-generated changes without human review, and do not claim indexing, income, deployment success, or ranking improvements without measured evidence.