Running tsc from the Windows command line
I'll share a couple of gotchas (that got me!) when I installed typescript (I followed https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html) on windows 10. I had earlier setup node by following the instructions at https://github.com/coreybutler/nvm-windows after failing miserably with other approaches.
Gotcha #1 - Both tsc and tsc.cmd are on the path (at %NVM_SYMLINK%) but tsc is the bash script. In other words you have to use the command tsc.cmd in order to actually invoke the windows version! Just invoking tsc will (in my Powershell terminal) cause it to fall over with weird errors.
Gotcha #2 - Windows file system locking semantics strikes again! Because I had been digging into the problem, I had the tsc.cmd file open in an editor - which was locking the file! This causes the correct invocation (tsc.cmd) to also fail.. till I closed the editor.
Hope this helps someone..
You should not add TypeScript's bin
folder directly to the Windows PATH
. As you noticed, the files in that bin
folder are not directly executable from the command line.
Instead, npm
creates a .cmd
script for every configured executable in a globally installed package and puts it in:
%APPDATA%\npm
Try updating your PATH
to include this folder, re-open your command line and try running tsc
again.
Side note: the Node.js installer for Windows by default adds Node and NPM to your Windows path. If you have installed Node.js normally, this should have worked just fine. Anything special about how you have your Node set up?