title: Using PouchDB in an Angular2 Cli Application with SystemJS and TypeScript
body: <p>I've searched through dozens of questions and answers on GitHub and Stack Overflow for the past two days. I haven't found a solution yet. Hopefully someone here can help me!</p>
  <p>I have gotten PouchDB working in development mode, using <code>ng serve</code> and <code>ng build</code>, however, when I try to build for production, using <code>ng build --prod</code>, it encounters an error:</p>
  <blockquote>
  <p>...</p>
  <p>Error: Unable to calculate canonical name to bundle file:///home/josiah/Projects/www/projectname/vendor/pouchdb/dist/pouchdb.js. Ensure that this module sits within the baseURL or a wildcard path config.</p>
  <p>...</p>
  </blockquote>
  <p>My current Angular2 Cli generated <code>system-config.ts</code> contains:</p>
  <pre><code>const map: any = {
    'pouchdb': './vendor/pouchdb/dist/',
  };
  </code></pre>
  <p>and</p>
  <pre><code>const packages: any = {
     &quot;pouchdb&quot;: {
        main: &quot;pouchdb&quot;,
        defaultExtension: &quot;js&quot;
     }
  };
  </code></pre>
  <p>In <code>angular-cli-build.json</code> I have added <code>'pouchdb/dist/*.+(js|js.map)',</code>.</p>
  <p>I am using <code>PouchDB</code> in my project with this import: <code>import * as PouchDB from 'pouchdb';</code></p>
  <p>Any ideas or suggestions are welcome! Thank you!</p>