title: Angular2 - Angular-CLI installing lodash - Cannot find module
body: <p>Mac OSX El capitan | angular-cli: 0.1.0 | node: 5.4.0 | os: darwin x64</p>
  
  <p>I try to install a 3rd party npm module according to the angular-cli wiki: <a href="https://github.com/angular/angular-cli/wiki/3rd-party-libs" rel="noreferrer">https://github.com/angular/angular-cli/wiki/3rd-party-libs</a> but fail. I've been struggling with this for days now and would greatly appreciate any help.</p>
  
  <p>Steps to get the error:</p>
  
  <p><code>ng new lodashtest3
  cd lodashtest3
  npm install lodash --save
  typings install lodash --ambient --save</code></p>
  
  <p>angular-cli-build.json:</p>
  
  <p><code>module.exports = function(defaults) {
    return new Angular2App(defaults, {
      vendorNpmFiles: [
        ...
        'lodash/**/*.js'
      ]
    });
  };
  </code>
  <code>ng build</code>
  (lodash gets correctly added in dist/vendor)</p>
  
  <p>system-config.ts:</p>
  
  <pre><code>/** Map relative paths to URLs. */
   const map: any = {
     'lodash': 'vendor/lodash/lodash.js'
   };
  
   /** User packages configuration. */
   const packages: any = {
     'lodash': {
       format: 'cjs'
     }
   };
  </code></pre>
  
  <p>(all according to spec in 
  <a href="https://github.com/angular/angular-cli/wiki/3rd-party-libs" rel="noreferrer">https://github.com/angular/angular-cli/wiki/3rd-party-libs</a>)
  Note - I've tried all config settings I can think of here, all giving the same result.</p>
  
  <p>lodashtest3.component.ts:
  <code>import * as _ from 'lodash';</code></p>
  
  <p><code>ng build</code></p>
  
  <pre><code>Could not start watchman; falling back to NodeWatcher for file system events.
  Visit http://ember-cli.com/user-guide/#watchman for more info.
  Build failed.
  The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
  Error: Typescript found the following errors:
    /Users/danielmattsson/git/lodashtest3/tmp/broccoli_type_script_compiler-input_base_path-g2lDIaq6.tmp/0/src/app/lodashtest3.component.ts (2, 20): Cannot find module 'lodash'.
      at BroccoliTypeScriptCompiler._doIncrementalBuild (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:115:19)
      at BroccoliTypeScriptCompiler.build (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:43:10)
      at /Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:152:21
      at lib$rsvp$$internal$$tryCatch (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1036:16)
      at lib$rsvp$$internal$$invokeCallback (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1048:17)
      at lib$rsvp$$internal$$publish (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1019:11)
      at lib$rsvp$asap$$flush (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1198:9)
      at nextTickCallbackWith0Args (node.js:456:9)
      at process._tickCallback (node.js:385:13)
  
  The broccoli plugin was instantiated at:
      at BroccoliTypeScriptCompiler.Plugin (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/broccoli-plugin/index.js:10:31)
      at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:21:10)
      at BroccoliTypeScriptCompiler (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:26:49)
      at Angular2App._getTsTree (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/lib/broccoli/angular2-app.js:280:18)
      at Angular2App._buildTree (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/lib/broccoli/angular2-app.js:101:23)
      at new Angular2App (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/lib/broccoli/angular2-app.js:42:23)
      at module.exports (/Users/danielmattsson/git/lodashtest3/angular-cli-build.js:6:10)
      at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:55:19)
      at Class.module.exports.Task.extend.init (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:89:10)
      at new Class (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/node_modules/core-object/core-object.js:18:12)
      at Class.module.exports.Task.extend.run (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/lib/tasks/build.js:15:19)
      at /Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/lib/commands/build.js:32:24
      at lib$rsvp$$internal$$tryCatch (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1036:16)
      at lib$rsvp$$internal$$invokeCallback (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1048:17)
      at /Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:331:11
      at lib$rsvp$asap$$flush (/Users/danielmattsson/git/lodashtest3/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1198:9)
  </code></pre>
  
  <p>EDIT: more information according to comments below</p>
  
  <p>dist/index.html:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Lodashtest3&lt;/title&gt;
    &lt;base href="/"&gt;
  
    &lt;link rel="icon" type="image/x-icon" href="favicon.ico"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  
    &lt;!-- Service worker support is disabled by default.
         Install the worker script and uncomment to enable.
         Only enable service workers in production.
    &lt;script type="text/javascript"&gt;
      if ('serviceWorker' in navigator) {
        navigator.serviceWorker.register('/worker.js').catch(function(err) {
          console.log('Error installing service worker: ', err);
        });
      }
    &lt;/script&gt;
    --&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;lodashtest3-app&gt;Loading...&lt;/lodashtest3-app&gt;
  
    &lt;script src="vendor/es6-shim/es6-shim.js"&gt;&lt;/script&gt;
    &lt;script src="vendor/reflect-metadata/Reflect.js"&gt;&lt;/script&gt;
    &lt;script src="vendor/systemjs/dist/system.src.js"&gt;&lt;/script&gt;
    &lt;script src="vendor/zone.js/dist/zone.js"&gt;&lt;/script&gt;
  
    &lt;script&gt;
      System.import('system-config.js').then(function () {
        System.import('main');
      }).catch(console.error.bind(console));
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>