Running tsc from the Windows command line
<p><strong>npm</strong> is installed and is actively being used from IntelliJ IDEA 15</p>

<p>My goal is to generate typings for my TypeScript source code in IntelliJ, but I want to learn using the Windows command line, so I can explicitly specify the command line options to tinker to understand what each option does. I am confused by the various tidbits related to setting this up and using it that I've found by Googling... I'm sure that I'm missing something very basic that those who blog or answer questions assume as common knowledge...</p>

<p>Here's what I've attempted and what I'm seeing...</p>

<p><strong>Step 1</strong>: install typescript:</p>

<p><code>npm install -g typescript</code></p>

<p>This results in the following file/directory structure being installed on my system:</p>

<pre><code>C:\Users\{my user id}\AppData\Roaming\npm\node_modules\typescript
|---bin
|   |--- tsc
|   |--- tscserver
|---lib
|   |--- lib.core.d.ts
|   |--- ...
|   |--- typescriptServices.js
|--- .npmignore
|--- ...
|--- ThirdPartyNoticeText.txt
</code></pre>

<p><strong>Step 2</strong>: naively try to run <code>tsc</code> directly from the Windows command line:</p>

<p>The examples that I've found by Googling take the form:</p>

<p><strong><em>Compile a single file:</em></strong></p>

<p><code>tsc app.ts</code></p>

<p>above example is from <a href="http://www.primordialcode.com/blog/post/typescript-command-line-compiler" rel="noreferrer">http://www.primordialcode.com/blog/post/typescript-command-line-compiler</a></p>

<p>This does not work as shown because:</p>

<ol>
<li><p>The install directory of <code>tsc</code> is not on the Windows <strong><code>Path</code></strong> <code>C:\Users\{my user id}\AppData\Roaming\npm\node_modules\typescript\bin</code>, obviously this is easily remedied or worked around by changing the Window PATH environmental variable and/or fully qualifying the path to the <code>tsc</code> file when entering the command to execute.</p></li>
<li><p>More significantly the <code>tsc</code> file is not a Windows executable... the <code>#!</code> Unix script (<a href="https://en.wikipedia.org/wiki/Shebang_(Unix)" rel="noreferrer">shebang</a>) being a dead giveaway.</p></li>
</ol>

<p>Inspecting the <code>tsc</code> file:</p>

<pre><code>#!/usr/bin/env node
require('../lib/tsc.js')
</code></pre>

<p><strong>Step 3</strong>: try to run <code>tsc</code> from the node command prompt:</p>

<p><code>C:\&gt;</code><strong><code>node</code></strong></p>

<p><code>&gt;</code> <strong><code>tsc</code></strong></p>

<pre><code>ReferenceError: tsc is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.&lt;anonymous&gt; (repl.js:417:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)

^C
</code></pre>

<p>OK... let's specify the full path to the <code>tsc</code> script:</p>

<p><code>C:\&gt;</code><strong><code>node</code></strong></p>

<p><code>&gt;</code> <strong><code>C:\Users\{my user id}\AppData\Roaming\npm\node_modules\typescript\bin\tsc</code></strong></p>

<pre><code>...
</code></pre>

<p>literally the only output is <strong><code>...</code></strong> when specifying the full path to the <code>tsc</code> script... I guess that it wants parameters... but hitting the <code>tab</code> key reveals a list of what seem to be <strong>node</strong> commands (not <code>tsc</code> commands)... so I've no idea what's going on here...</p>

<p>Now I'm stuck</p>

<p>What environment do I need to install/configure/use to invoke <code>tsc</code> (as illustrated by: <a href="http://www.primordialcode.com/blog/post/typescript-command-line-compiler" rel="noreferrer">http://www.primordialcode.com/blog/post/typescript-command-line-compiler</a>)?</p>

<p>and/or</p>

<p>Is there a tutorial or site that would help me go from a clean Windows system to being able to use the TypeScript compiler from the command line to generate typings for my TypeScript source files?</p>