This is not the tsc command you are looking for

Viewed 14757

When I run tsc in the terminal (it does not matter where) I get returned:

This is not the tsc command you are looking for

enter image description here

I do not have TypeScript installed globally to my knowledge so what I am expecting is that It can't find tsc.

9 Answers

The problem in my case was that I had installed tsc package instead of the correct typescript.


The fix is:

npm uninstall tsc

On my Mac, this fixed it:

npm uninstall -g typescript
npm install -g typescript

When I was fooling around trying to get started, i had done something like this:

npm install -g tsc   #bad, don't do this

which had screwed up my install.

There is nothing to do as it's a very easy problem. Go to your vs code folder where you have installed node package. For example, in my system, it is:

C:\Users\vivek\AppData\Roaming\npm

First of all you will notice that both the tscServer and tsc files are not created. So first delete all the tsc files, then go to the vs code and uninstall typeScript like this:

npm uninstall typescript

Then again install the typescript like this:

npm install -g typescript

I had installed the old typescript compiler https://www.npmjs.com/package/tsc by mistake.

running where.exe tsc to find out what I was actually running suggested by @siddharth made me find the issue

this solved the issue for me.

    npm uninstall typescript
    npm uninstall tsc
    npm install typecript -g

If using Volta or similar version managers you can do

npm remove -g typescript tic
pnpm remove -g typescript (if using pnpm)

and install it again with your node package manager of choice (globally)!

With typescript already installed both as a devDependency and globally, for me the solution was updating a package.json script:

Before:

{
  "scripts": {
    "build": "pnpx tsc ..."
  }
}

After:

{
  "scripts": {
    "build": "tsc ..."
  }
}

Perhaps everyone else knew that p/npx is not needed in scripts, but I didn't.

Hope this helps someone.

Related