title: Serverless Offline: Error while running handler, cannot find module
body: <p>I've been trying to use <code>serverless-offline</code> / <code>serverless-offline-python</code> and a family of other node packages (<code>serverless-s3-local</code> for example) to build an offline testing environment for some lambdas that I've written.</p>
  
  <p>Using <code>serverless-offline-python</code>, I am able to start my python lambdas and invoke each function manually with:</p>
  
  <pre><code>sls offline start --stage local --noTimeout --watch --port 3000
  sls invoke local --stage local -f import-processor-stage-1 -d '{"event": "", "context": ""}'
  </code></pre>
  
  <p>This works, but doesn't quite simulate what the lambda is actually doing. Ideally, I would simulate an S3 bucket having a new object imported and that action would be the catalyst for the lambda (<code>import-processor-stage-1</code>). </p>
  
  <p><a href="https://github.com/ar90n/serverless-s3-local" rel="nofollow noreferrer"><em>Enter</em> <code>serverless-s3-local</code></a>.</p>
  
  <p>I've rigged up a pretty fantastic configuration with the plugin, but for some reason when <code>serverless-s3-local</code> goes to trigger an event to my lambda handler, I receive this error:</p>
  
  <pre><code>Error while running handler { Error: Cannot find module '/Users/user/Documents/project/manager/infra/main/import_processor_stage_1'
      at Function.Module._resolveFilename (module.js:547:15)
      at Function.Module._load (module.js:474:25)
      at Module.require (module.js:596:17)
      at require (internal/module.js:11:18)
      at Object.createHandler (/usr/local/lib/node_modules/serverless-offline/src/functionHelper.js:167:17)
      at Object.func (/Users/user/node_modules/serverless-s3-local/index.js:308:50)
      at /Users/user/node_modules/serverless-s3-local/index.js:170:11
      at SafeSubscriber.s3eventSubscription.client.s3Event.pipe.subscribe [as _next] (/Users/user/node_modules/serverless-s3-local/index.js:176:7)
      at SafeSubscriber.__tryOrUnsub (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:270:10)
      at SafeSubscriber.next (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:212:14)
      at Subscriber._next (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:141:22)
      at Subscriber.next (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:101:12)
      at MergeMapSubscriber.notifyNext (/Users/user/node_modules/rxjs/src/internal/operators/mergeMap.ts:159:22)
      at InnerSubscriber._next (/Users/user/node_modules/rxjs/src/internal/InnerSubscriber.ts:17:17)
      at InnerSubscriber.Subscriber.next (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:101:12)
      at /Users/user/node_modules/rxjs/src/internal/util/subscribeToArray.ts:9:16
      at Object.subscribeToResult (/Users/user/node_modules/rxjs/src/internal/util/subscribeToResult.ts:25:29)
      at MergeMapSubscriber._innerSub (/Users/user/node_modules/rxjs/src/internal/operators/mergeMap.ts:145:5)
      at MergeMapSubscriber._tryNext (/Users/user/node_modules/rxjs/src/internal/operators/mergeMap.ts:138:10)
      at MergeMapSubscriber._next (/Users/user/node_modules/rxjs/src/internal/operators/mergeMap.ts:122:12)
      at MergeMapSubscriber.Subscriber.next (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:101:12)
      at MapSubscriber._next (/Users/user/node_modules/rxjs/src/internal/operators/map.ts:86:22)
      at MapSubscriber.Subscriber.next (/Users/user/node_modules/rxjs/src/internal/Subscriber.ts:101:12)
      at Subject.next (/Users/user/node_modules/rxjs/src/internal/Subject.ts:68:17)
      at triggerS3Event (/Users/user/node_modules/s3rver/lib/controllers.js:56:21)
      at store.putObject (/Users/user/node_modules/s3rver/lib/controllers.js:498:11)
      at storeMetadata.err (/Users/user/node_modules/s3rver/lib/stores/filesystem.js:291:13)
      at /Users/user/node_modules/graceful-fs/graceful-fs.js:111:16
      at /usr/local/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:43:10
      at FSReqWrap.oncomplete (fs.js:135:15) code: 'MODULE_NOT_FOUND' }
  </code></pre>
  
  <p>Sadly, I know that these plugins are in their enfancy (particularly <code>serverless-offline-python</code>), but I am quite sure that this should be a very easy fix. The module that is not found actually exists within the package! Im thinking that it is because it is a Python file and not a JS file. Is there a way within the js script to accept python files? So far, I have tried replacing all references of <code>serverless-offline</code> with <code>serverless-offline-python</code> within the <code>serverless-s3-local</code> code base, but I get the same error.</p>
  
  <p>For reference, here is my <code>serverless.yml</code> file (for the record, the handler file is available, correctly located and works fine while manually invoking it):</p>
  
  <pre><code>service: catalog-import-manager
  
  plugins:
   - serverless-s3-local
   - serverless-dynamodb-local
   - serverless-offline-python
  
  provider:
    name: aws
    runtime: python3.6
    region: us-west-2
  
  
  custom:
    s3:
      port: 8090
      directory: s3-simulated-buckets
      cors: false
  
  
  resources:
    Resources:
      stage-one:
        Type: 'AWS::DynamoDB::Table'
        Properties:
          AttributeDefinitions:
            -
              AttributeName: import_id
              AttributeType: S
          KeySchema:
            -
              AttributeName: import_id
              KeyType: HASH
          ProvisionedThroughput:
            ReadCapacityUnits: 1
            WriteCapacityUnits: 1
          TableName: stage-one
  
      ImportBucket:
        Type: AWS::S3::Bucket
        Properties:
          BucketName: import
  
  
  functions:
    import-processor-stage-1:
      handler: import_processor_stage_1.process_file_import
      events:
        - existingS3:
            bucket: import
            events:
              - s3:ObjectCreated:*
  </code></pre>
  
  <p>Any and all help is appreciated! Thank you for taking a look!</p>
  
  <hr>
  
  <p>Can confirm that this works for a js environment.</p>