Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

The shell says tsc is not found after installing TypeScript

Errortsc: command not found

Short answer

tsc is a program that the typescript package installs. A local install puts it in node_modules/.bin, which your shell does not search, while a global install links it into npm's bin folder, which must be on PATH. Install it, then run it with npx or an npm script.

  • Applies to Node.js 22, npm 10, TypeScript 5, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See whether the project already holds the compiler in its local bin folder.

    ls node_modules/.bin/tsc
  2. 2Match what you see, then jump to its fix

    1. 1ls node_modules/.bin/tsc reports no such fileTypeScript is not installed in the projectFix
    2. 2ls node_modules/.bin/tsc shows the file, yet tsc alone is not foundIt is installed locally, and you typed tsc in the shellFix
    3. 3npm install -g typescript succeeded, a new shell still cannot find tscInstalled globally, but npm's bin folder is not on PATHFix

What does the error look like?

  • tsc: command not found

Cause 1 of 3

TypeScript is not installed in the project

1Check

Look for typescript in the dependencies.

grep -n "typescript" package.json

2Fix

Install it as a dev dependency, then run it through npx.

npm install typescript --save-dev
npx tsc --version

3Verify

npx should print the compiler version.

npx tsc --version

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

It is installed locally, and you typed tsc in the shell

1Check

npm places local executables in ./node_modules/.bin so that npm scripts find them. The shell does not look there. npx puts locally installed bins on the PATH of the command it runs.

ls -l node_modules/.bin/tsc

2Fix

Call it with npx, or add a script to package.json and run that.

npx tsc

# package.json
"scripts": { "build": "tsc" }

npm run build

3Verify

The build should run and write its output.

npm run build

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

Installed globally, but npm's bin folder is not on PATH

1Check

npm links global executables into the bin folder under its prefix, and the docs say that folder must be in your terminal's PATH. On Unix it is prefix/bin; on Windows it is the prefix itself.

echo $PATH

2Fix

Add the folder to PATH in your shell profile, open a new terminal and try again. For team projects a local install is easier to repeat.

npm install -g typescript

3Verify

Open a new terminal and check the version.

tsc --version

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Keep typescript in devDependencies and call it only from npm scripts or npx, so every machine uses the same version.
  • Add a build script to package.json instead of documenting a bare tsc command.
  • Commit the lockfile so CI installs the same compiler.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

cdk synth says --app is required

--app is required either in command-line, in cdk.json or in ~/.cdk.json

The CDK CLI needs a command that runs your app and finds it in three places: the --app option, cdk.json in the project folder, or cdk.json in your home folder.

3 causes, each with a fix

Back end

Mocha or Node cannot find ts-node/register

Error: Cannot find module 'ts-node/register'

Node resolves ts-node/register from your project's node_modules, so the package must be installed there, next to typescript.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.