Reputation: 2888
When I run tsc
in the terminal (it does not matter where) I get returned:
$ npx tsc --version
This is not the tsc command you are looking for
To get access to the TypeScript compiler, tsc, from the command line either:
- Use npm install typescript to first add TypeScript to your project before using npx
- Use yarn to avoid accidentally running code from un-installed packages
I do not have TypeScript installed globally to my knowledge so what I am expecting is that it can't find tsc
.
Upvotes: 73
Views: 58500
Reputation: 1
For typescript ^5.1.x
Upvotes: -1
Reputation: 238
I managed to fix this issue by deleting the node_modules
folder, and re-running yarn install
.
Upvotes: -1
Reputation: 354
I have to uninstall tsc
from my package.json. It was not supposed to be there; the typescript
lib is enough.
Upvotes: 0
Reputation: 5336
I avoid installing global dependencies, to keep my environment clean and deterministic.
=> I prefer to fix this problem by specifying the package that npx must use:
$ npx --package typescript tsc --version
Upvotes: 5
Reputation: 69
if You are getting tsc command error just run it on your terminal
npm install -g typescript --force
Upvotes: 6
Reputation: 2603
The tsc module is DEPRECATED! You only need the typescript module, if you need tsc!
Install the typescript module by:
npm install -D typescript
Upvotes: 5
Reputation: 993
The problem in my case was that I had installed tsc
package instead of the correct typescript
. From https://www.npmjs.com/package/tsc:
Use
typescript
to get access to thetsc
CLI command.
The fix is:
npm uninstall tsc
npm install -D typescript
Commands like npx tsc --version
will still run because typescript
provides the tsc
executable.
Upvotes: 98
Reputation: 107
npm uninstall tsc
, it will remove all the .bin/tcs folder.npm install typescript
, it will fix the issue.Upvotes: 0
Reputation: 1
go to tsc.cmd
or tsc.ps1
path
look likes this
node_module
typescript // remove this
other...
tsc.cmd // remove this
other...
then
npm install -g typescript@latest
Upvotes: -1
Reputation: 741
in my mac it worked only after adding 'force' flag to the command:
npm uninstall -g typescript --force
npm install -g typescript --force
Upvotes: -1
Reputation: 317
This solved the issue for me:
npm uninstall typescript
npm uninstall tsc #local tsc package
npm install typescript -g
Upvotes: 4
Reputation: 1
tsc is typescript/bin/tsc
, so must uninstall tsc
first.
[1] https://i.sstatic.net/mUK0o.png
Upvotes: -1
Reputation: 99
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\vivekranjan\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
Upvotes: 9
Reputation: 5427
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.
Upvotes: 3
Reputation: 1
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)!
Upvotes: -1
Reputation: 1058
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.
Upvotes: 31
Reputation: 99
Try chocolatey manager for typescript installation https://community.chocolatey.org/packages/typescript
choco install typescript
Upvotes: -1
Reputation: 2888
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
Upvotes: 3