Reputation: 519
I am using node version 6.9.2 with npm version 5.4.2 on Windows7. I have installed typescript with the command npm install typescript -g
.
However, when I run a demo file using command, tsc
, I get an error:
"tsc is not recognized as an internal or external command".
Could anybody help? Other node modules get installed correctly and working fine. Not sure why typescript isn't working.
Upvotes: 3
Views: 13497
Reputation: 1
I found this solution in this website and it worked for me.
-> If you are on windows and getting this error "'tsc' is not recognized as an internal or external command."
Solution -> add the following path "C:\Users\user\AppData\Roaming\npm" to the PATH variable replace user with your windows user. -> Restart the System.
Reference:- https://www.typescripttutorial.net/typescript-tutorial/setup-typescript/
Upvotes: 0
Reputation: 18401
Since you installed it globally and you had no error, I can assume that the installation succeeded.
To be sure, you can run this command npm config get prefix
. It will output the path of the folder containing all packages installed globally by npm. I you go to the folder specified by the path, there is a nodes_modules
subfolder. It should contain a typescript folder if the installation succeeded. Then copy the path of the bin
of the typescript folder in your environment variable. You should label the path tsc
.
Then you can use tsc
in command line.
Upvotes: 1
Reputation: 697
The problem is likely that tsc
is not in the system path.
First, check if tsc
is installed correctly. Open cmd.exe
and type the following.
%AppData%\npm\node_modules\typescript\bin\tsc --version
If there is a version log, then tsc
is installed successfully.
The next thing is to add it in PATH. Write in cmd.exe
setx path "%path%;%AppData%\npm\node_modules\.bin\"
This should solve the issue.
However, if the first command did not log the version,
Check the install location using
npm list -g
If typescript appears in the output, copy the location to the PATH as
setx path "%path%;<--the tsc.exe path-->"
Hope this helps.
Upvotes: 4