title: Handler in subdirectory of AWS Lambda function not running
body: <p>I'm getting an awfully unfortunate error on Lambda:</p>
  
  <pre><code>Unable to import module 'lib/index': Error
  at require (internal/module.js:20:19)
  </code></pre>
  
  <p>Which is strange because there is definitely a function called <code>handler</code> getting exported from <code>lib/index</code>...not sure if the whole subdirectory thing has been an issue for others so I wanted to ask.</p>
  
  <h2>sam-template.yaml</h2>
  
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  Description: Does something crazy
  Resources:
    SomeFunction:
      Type: AWS::Serverless::Function
      Properties:
        Handler: lib/index.handler
        Role: arn:aws:iam::...:role/lambda-role
        Runtime: nodejs6.10
        Timeout: 10
        Events:
          Timer:
            Type: Schedule
            Properties:
              Schedule: rate(1 minute)
  </code></pre>
  
  <h2>Module structure</h2>
  
  <pre><code>|-- lib
  |     `-- index.js
  `-- src
        `-- index.js
  </code></pre>
  
  <p>I have nested it here because I'm transpiling ES6 during my build process using the following, excerpt from <code>package.json</code>:
  <code>"build": "babel src -d lib"</code></p>
  
  <h2>buildspec.yaml</h2>
  
  <pre><code>version: 0.1
  phases:
      install:
          commands:
              - npm install
              - aws cloudformation package --template-file sam-template.yaml --s3-bucket some-bucket --output-template-file compiled-sam-template.yaml
      build:
          commands:
              - npm run build
      post_build:
          commands:
              - npm prune --production
  artifacts:
      files:
          - 'node_modules/**/*'
          - 'lib/**/*'
          - 'compiled-template.yaml'
  </code></pre>