Reputation: 3870
I have a MacBook Pro with OS X 10.8.2 Some time ago I installed Typescript and today I'd like to upgrade that installation to the latest version available (so far, v0.8.3). I wrote this command from the terminal:
sudo npm install -g typescript
But this is what I got on the display:
npm http GET https://registry.npmjs.org/typescript
npm http 304 https://registry.npmjs.org/typescript
/usr/local/bin/tsc -> /usr/local/lib/node_modules/typescript/bin/tsc
[email protected] /usr/local/lib/node_modules/typescript
Does this means that I still have version 0.8.0 installed on my computer?
I tried to see if the tsc command has a -v
or a -version
parameter but I haven't found it, so I still uncertain if I have upgraded Typescript to the latest release or if I'm still stuck with an older version.
Upvotes: 58
Views: 118610
Reputation: 2043
UPDATE 9/26/2022
After running npm install typescript@latest -g
I got the errors:
npm ERR! code EEXIST
npm ERR! path C:\Users\chrisds\AppData\Roaming\npm\tsc
npm ERR! EEXIST: file already exists
npm ERR! File exists: C:\Users\chrisds\AppData\Roaming\npm\tsc
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\chrisds\AppData\Local\npm-cache\_logs\2022-09-26T20_55_57_959Z-debug-0.log
So I found the path and deleted all instances of tsc i.e.: tsc
, tsc.cmd
, tsc.psl
, tsserver
, tsserver.cmd
, tsserver.psl
And then ran npm install typescript@latest -g
again and it worked.
C:\Users\chrisds\Documents\typescript-angular>tsc -v
Version 4.8.3
Upvotes: 1
Reputation: 119
I know this is an old Question, but I faced a similar issue and none of the answers here solved it, posting my answer for anyone else in the same boat.
Upvotes: 2
Reputation: 22672
Open a command line tool cmd.exe/Git Bash
and execute:
npm install -g typescript@latest
The command will do the following:
Check if Typescript is installed and ..
It has been reported that the following command will not work reliably when you already have typescript installed:
npm update -g typescript@latest
Test the version using
tsc -v // prints out the locally installed typescript version
Furthermore you can check, which is the latest available version for typescript in the npm registry:
npm view typescript version // prints the latest available version in the npm registry
Upvotes: 14
Reputation: 2395
I encountered the same issue and none of the popular answers resolved the problem for me. I'm on Windows 10 with Visual Studio 2017.
I tried using where tsc
from the console to determine where the path to tsc
was resolving. The first entry was similar to: C:\Program Files (x86)\Microsoft SDKs\TypeScript\x.xx
. So I checked the PATH
variable (both System and User) and that path was nowhere to be found.
I finally stumbled across this comment on GitHub: https://github.com/Microsoft/TypeScript/issues/4971#issuecomment-144184935
Which pointed me in the right direction. I use Console2
and my default console tab spawns a Visual Studio-enhanced console via this .bat
file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat
That .bat
file doesn't contain anything TypeScript-specific, but it does run all the .bat
files found in C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\vsdevcmd\ext
. And one of those files is conspicuously named typescript.bat
. I simply renamed that filed to some other extension, then re-opened a console and now everything is great.
Not sure if this will bork up anything in Visual Studio, but I don't use it for TypeScript. And I suspect a future Visual Studio update may put that file back in place. But it works for now.
Upvotes: 0
Reputation: 5058
I just faced this issue on the windows 8 machine with blocked admin access where I was unable to uninstall global typescript, modify PATH
etc.
Here's how to launch typescript projects in this case:
npm install typescript@latest
( avoid -g
param)add build scripts to package.json
e.g.
scripts: {
"clean": "rimraf coverage build tmp",
"build": "tsc -p tsconfig.release.json",
"build:watch": "tsc -w -p tsconfig.release.json",
"lint": "tslint -t stylish --project \"tsconfig.json\"",
"test": "jest --coverage",
"test:watch": "jest --watch"
}
run typescript compiler with the local version of typescript via npm run build:watch
which will launch tsc -w -p tsconfig.release.json
using project's local tsc
from node_modules
Upvotes: 2
Reputation: 2148
I had the same problem on Linux, possibly related to using node version manager.
I fixed it by finding where tsc was and then manually going in and deleting those folders
$ which tsc
/home/vagrant/.nvm/versions/node/v6.9.5/bin/tsc
$ cd /home/vagrant/.nvm/versions/node/v6.9.5/bin/
$ ll
...
lrwxrwxrwx 1 vagrant vagrant 38 Nov 30 10:32 tsc -> ../lib/node_modules/typescript/bin/tsc*
lrwxrwxrwx 1 vagrant vagrant 43 Nov 30 10:32 tsserver -> ../lib/node_modules/typescript/bin/tsserver*
...
$ rm -rf ../lib/node_modules/typescript/ tsc tsserver
Upvotes: 3
Reputation: 3870
I just realised that I was using an old version of npm. I have upgraded npm to the latest version, then re-installed typescript and now I have the latest version of typescript installed on my computer.
Upvotes: 9
Reputation: 688
Even when i installed latest typescript, still i was getting version as 1.0.3 when doing tsc -v
The corrected answer didn't help me , but followed @BenR approach, removed this PATH C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\ from System Variables
and then opened new windows command prompt and then typed
tsc -v
Version 2.3.3
So now i was able to compile the typescript files using tsc file.ts
Hope this helps someone.
Upvotes: 14
Reputation: 1193
I had the same problem below procedure worked for me
Update NPM
npm install npm@latest -g
Update typescript
npm -g upgrade typescript
or
npm install typescript@latest -g
now you should see
tsc --version
Version 2.1.5
Upvotes: 81
Reputation: 4145
For those still struggling with that - try running WHERE tsc
in Command Prompt or Node.js Command Prompt and you'll get all the locations it is installed. Remove the excessive location from PATH env var.
Upvotes: 17
Reputation: 2936
Since selected correct answer didn't help me I figured I'd share how I resolved the issue.
I had to remove C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
from my PATH.
After that I could run this command and see the version I was expecting:
C:\>tsc --version
message TS6029: Version 1.5.3
Upvotes: 78