Home·Error messages

shell · npm

The message

zsh: command not found: tsc

What it means

The shell searched PATH and found no executable by that name — the install itself may well have succeeded. It happens when npm's global bin directory is not on PATH, when you installed locally rather than globally so the binary went into node_modules/.bin, or when the shell is holding an old PATH in its cache. npx tsc --version runs the local copy without touching PATH at all, so that one line separates not installed from not on PATH. For a genuinely global install, add the output of npm prefix -g plus /bin to PATH and open a new shell.

The fix

npx tsc --version
Printed by
shell
npm
20

With npm the cause sits in the first code XXXX line rather than the last six npm ERR! lines, and when the failure comes from the dependency tree or a native build instead of your own code, deleting node_modules and installing again clears about half of them.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “zsh: command not found: tsc” mean?

The shell searched PATH and found no executable by that name — the install itself may well have succeeded. It happens when npm's global bin directory is not on PATH, when you installed locally rather than globally so the binary went into node_modules/.bin, or when the shell is holding an old PATH in its cache. npx tsc --version runs the local copy without touching PATH at all, so that one line separates not installed from not on PATH. For a genuinely global install, add the output of npm prefix -g plus /bin to PATH and open a new shell.

Q. How do I fix it?

npx tsc --version — before running it, check the explanation above for what this command discards.

Q. Which tool prints this?

shell. It sits under npm, and the message runs to 5 words.

Errors nearby