title: How would I import a module within an npm package subfolder with webpack?
body: <p>Lets say theres a package in <code>node_modules</code> called foo and I want to import a module within a library such as <code>foo/module</code> via webpack &amp; babel...</p>
  
  <p><code>import Foo from 'foo';</code> works</p>
  
  <p><code>import SomeOtherModule from 'foo/module';</code> fails with the following:</p>
  
  <blockquote>
    <p>Module not found: Error: Cannot resolve module 'foo/module' in
    /Users/x/Desktop/someproject/js</p>
  </blockquote>
  
  <p>Which makes make it seem like webpack is looking for the file in the wrong place instead of <code>node_modules</code></p>
  
  <p>My webpack.config looks like this:</p>
  
  <pre><code>var webpack = require('webpack');
  var path = require('path');
  
  module.exports = {
      entry: ['babel-polyfill','./js/script.js'],
      output: {
          path: __dirname,
          filename: './build/script.js'
      },
      module: {
          loaders: [
              {
                  test: /\.js$/,
                  loader: 'babel',
                  query: {
                      cacheDirectory: true,
                      presets: ['es2015']
                  }
              }
          ],
      },
      plugins: [
          new webpack.NoErrorsPlugin()
      ],
      stats: {
          colors: true
      },
      devtool: 'source-map'
  
  };
  </code></pre>