title: TypeScript won't resolve external module (node.js)
body: <p>I would like to use moment.js in my node application, so I installed moment.js using node's package manager npm:</p>
  
  <pre><code>npm install moment@2.4.0
  </code></pre>
  
  <p>Just to be on the safe side, I checked moment is not installed globally and the installed version is really version 2.4.0 (version 2.4.0 in order to use the correct d.ts file ...)</p>
  
  <pre><code>require("moment").version
  </code></pre>
  
  <p>Alright, seems to be good. I'm also using the latest version of TypeScript (0.9.5). </p>
  
  <p>So, now I added the following file to my projects root directory <a href="https://github.com/borisyankov/DefinitelyTyped/blob/master/moment/moment.d.ts">https://github.com/borisyankov/DefinitelyTyped/blob/master/moment/moment.d.ts</a> and refernced the file:</p>
  
  <pre><code>/// &lt;reference path="moment.d.ts" /&gt;
  </code></pre>
  
  <p>Now, it should work to import moment using TypeScripts import keyword:</p>
  
  <pre><code>import m = require("moment");
  </code></pre>
  
  <p>Compiling with the following command </p>
  
  <pre><code>tsc app.ts --module commonjs
  </code></pre>
  
  <p>produces the following errors</p>
  
  <blockquote>
    <p>/home/unknown/temp/test/app.ts(3,1): error TS2071: Unable to resolve
    external module '"moment"'. /home/unknown/temp/test/app.ts(3,1): error
    TS2072: Module cannot be aliased to a non-module type.</p>
  </blockquote>
  
  <p>Why does this error occur? How do I fix it?</p>