Resolving the “tsc Command Not Found” Issue in TypeScript
The message “tsc: command not found” appears when the TypeScript compiler is not available in your system’s executable path. This usually happens because TypeScript is not installed globally, because the PATH environment variable does not include the directory where global npm binaries are stored, or because TypeScript is installed only inside a specific project rather than system‑wide.
This guide explains why the error occurs, how to diagnose the underlying cause, and how to fix it on macOS, Linux, and Windows. The explanations focus on real‑world development setups and avoid unnecessary abstractions.
1. Why the Error Appears
Even though the error seems straightforward, it can come from several scenarios:
- TypeScript is not installed at all.
- TypeScript is installed but only locally in a single project.
- TypeScript is installed globally, but the system cannot find the executable because PATH is misconfigured.
- Node.js or npm is installed incorrectly or using a nonstandard directory.
- You are using version managers such as nvm, fnm, volta, or asdf and the environment is not fully initialized.
Understanding the exact cause helps avoid installing packages repeatedly without solving the underlying issue.
2. Check Whether TypeScript Is Installed
Start by checking if the compiler exists on your system:
tsc --versionIf the terminal returns the version number, TypeScript is globally available.
If the terminal responds with “command not found,” the system cannot locate the binary.
You can also check whether TypeScript exists locally inside a project:
npm list typescriptIf this returns a version, then TypeScript is installed but only within that project.
3. Installing TypeScript Globally
If you want tsc to be available in every folder on your machine, install it globally:
npm install -g typescriptAfter installation, verify:
tsc --versionIf the command still fails, the package may be installed correctly but the executable directory is not added to PATH.
4. Understanding the PATH Issue
npm installs global binaries in a specific folder. The operating system must know where that folder is. If the directory is not included in PATH, no command inside it can be executed by name.
Where npm stores global binaries
You can check the exact path with:
npm config get prefixInside this prefix, the executable binaries are located in:
<prefix>/binIf this directory is not part of PATH, the system does not know where tsc is.
5. Fixing PATH on macOS and Linux
To add the npm global binary directory to PATH, append the following line to your shell configuration file (~/.zshrc, ~/.bashrc, or ~/.profile):
export PATH="$PATH:$(npm config get prefix)/bin"After saving the file, reload your terminal:
source ~/.zshrc(or the configuration file you edited).
Now test:
tsc --versionIf the version appears, PATH is configured correctly.
6. Fixing PATH on Windows
On Windows, npm global binaries are commonly stored in:
C:\Users\<YourUser>\AppData\Roaming\npmTo add this directory to PATH:
- Open System Properties → Advanced → Environment Variables.
- Find Path under your user variables.
- Add the npm directory path from above.
- Restart your terminal.
After making the change, run:
tsc --versionIf TypeScript loads, the PATH was the underlying issue.
7. Running tsc with npx (When TypeScript Is Local)
If a project uses TypeScript locally and you do not want a global installation, the correct way to access the compiler is:
npx tsc --versionnpx automatically resolves the local version installed in the project’s node_modules folder.
This is the preferred approach in large multi-project repositories, monorepos, or CI environments.
8. Using Version Managers (nvm, fnm, volta, asdf)
Node version managers often cause confusion because each Node version has its own global package directory. If you switch Node versions without reinstalling global tools, the system may lose access to previous global installations.
For example, after switching Node versions with nvm:
nvm use 20
tsc --version # may failYou may need to reinstall TypeScript globally for the specific version managed by nvm:
npm install -g typescriptAlternatively, avoid global installations entirely and use npx in each project.
9. Checking Node.js and npm Installation
Since tsc is installed through npm, incorrect or partial installation of Node.js can cause the error.
Verify the installations:
node -v
npm -vIf either command fails, reinstall Node.js from:
Or, if using a version manager, reinstall Node within your environment.
10. Reinstall TypeScript When Necessary
If the installation is corrupted or incomplete, reinstalling can help:
npm uninstall -g typescript
npm install -g typescriptAlways verify after reinstalling:
tsc --version11. Global vs Local Installations: When Each Makes Sense
Global installation is useful when:
- You compile small scripts outside any project.
- You prefer running
tscwithoutnpx. - You need global CLIs available everywhere.
Local installation is better when:
- You work in teams and want consistent TypeScript versions.
- You maintain multiple projects with different configurations.
- You use CI environments that avoid global tools.
In modern setups, many developers rely primarily on local installations and npx, using global TypeScript only for experimentation or sysadmin scripts.
Conclusion
The “tsc: command not found” error is straightforward once you understand how npm installs global binaries and how PATH determines whether your system can locate them.
By verifying the installation, checking PATH configuration, and understanding the difference between global and local TypeScript setups, you can ensure that your development environment remains consistent and reliable.
Correct installation and configuration allow TypeScript to run smoothly and prevent this error from interrupting your workflow.