'tsc' is not recognized as an internal or external command on Windows when installed globally

Viewed 2155

I've seen bunch of 'tsc' is not recognized as an internal or external command issues here on StackOverflow but none of them could help me solve my problem.

I've installed typescript globally with:

npm install -g typescript

There are tsc and tsc.cmd files in C:\Users\<user_name>\AppData\Roaming\npm directory. So %AppData%\npm\tsc --version command works.

I've got C:\Users\<user_name>\AppData\Roaming\npm directory in my user's PATH.

More, when I run where tsc command in arbitrary directory, I get:

C:\Users\<user_name>\Desktop>where tsc
C:\Users\<user_name>\AppData\Roaming\npm\tsc
C:\Users\<user_name>\AppData\Roaming\npm\tsc.cmd

However, when I simply try to run tsc, I got:

C:\Users\<user_name>\Desktop>tsc
'tsc' is not recognized as an internal or external command,
operable program or batch file.

Exactly the same problem occurs with grunt and uglifyjs.

2 Answers

I managed to solve this problem.

C:\Users\<user_name>\AppData\Roaming\npm indeed was in user's PATH variable. I also have system variable called Path (yes, just first letter is uppercased) and there was no C:\Users\<user_name>\AppData\Roaming\npm in there.

When I added it to system's Path, it finally started to work.

Not sure that this is ok that two of my path variables have different names (in terms of cases). Also not sure that this situation led to problems. Would be glad if someone could clarify this.

Try installing the linux console for windows the cygwin console., And run the command tsc from that console, I know it does not change much but sometimes I have solved many problems with that console.

https://www.cygwin.com/

Related