title: Angular2 & TypeScript importing of node_modules
body: <p>I had a very simple 'hello world' Angular2 app. I also made the apparently unreasonable decision to work with different directory structures between my dev project and the final deployment folder on my spring backend.</p>
  
  <p>Because of this difference, I had an issue with the TypeScript imports, and this line ended up producing 404 errors (unable to find /angular2/core library) when I tried to open the actual app in my browser:</p>
  
  <pre><code>import {Component, View} from 'angular2/core';
  </code></pre>
  
  <p>So long story short, I ended up adding back the /app folder to make everything work, but I ended up modifying my import statements as follows:</p>
  
  <pre><code>import {Component, View} from '../node_modules/angular2/core';
  </code></pre>
  
  <p>This, however, turned out to cause some weird behavior. For some reason specifying <code>../node_modules</code> in the library paths is causing the JS to actually load ALL Angular2 files from scratch using ajax calls to retrieve each and every individual file from the <code>npm_modules/angular2/</code> folder even though this was part of my HTML header:</p>
  
  <pre><code>&lt;script src="/node_modules/angular2/bundles/angular2.dev.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>When I finally realized what's going on I reverted the import statement back to </p>
  
  <pre><code>import {Component, View} from 'angular2/core';
  </code></pre>
  
  <p>and it all worked. Angular2 was now completely loaded from the script tag above and there were no files getting loaded by extra ajax calls.</p>
  
  <p>Can someone please explain what is causing this? I assume it's normal behavior but I don't understand how the importing works and why specifying a more detailed path makes such a difference.</p>