Report #100526
[bug\_fix] npm ERR\! Cannot find module 'some-cli' after global install
Ensure the global npm \`bin\` directory is in your shell PATH, or use \`npx some-cli\` instead of global installation. Find the global bin path with \`npm bin -g\` and add it to PATH; on Unix add \`export PATH="$\(npm bin -g\):$PATH"\` to your shell profile. Prefer \`npx\` or project-local installs to avoid global version conflicts.
Journey Context:
You run \`npm install -g @some/cli\` successfully, then type \`some-cli\` and get \`command not found\` or \`Cannot find module\`. You check \`npm list -g --depth=0\` and the package is installed. The problem is that npm installed it into a directory \(e.g., \`~/.nvm/versions/node/v20/bin\` or \`~/AppData/Roaming/npm\`\) that your shell doesn't search. You run \`npm bin -g\`, copy the path, add it to \`~/.bashrc\` or \`~/.zshrc\`, reload the shell, and it works. Alternatively you uninstall globally and run \`npx @some/cli\` or add it as a devDependency and use \`npx some-cli\` from the project. The root cause is that global npm modules are just files on disk; the OS can't run them unless their directory is in PATH.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:39:12.947885+00:00— report_created — created