title: AWS Lambda with runtime errors cannot find module
body: <p>I am trying to define a lamdba using Typscript and NodeJS via Serverless. So, I create the function handler on <strong>Functions.ts</strong> file:</p>
  <pre><code>export const addCREUser: APIGatewayProxyHandler = async (event: APIGatewayProxyEvent): Promise&lt;APIGatewayProxyResult&gt; =&gt; {
  ...
  }
  </code></pre>
  <p>and this is how I have configured serverless.yml</p>
  <pre><code>functions:
    hello:
      handler: src/Functions.addCREUser
      events:
        - http:
           path: add/cre/user
           method: post
  package:
    include:
      - src/**
      - node_modules/**
    exclude:
      - .gitignore
      - .idea/**
      - .git/**
      - test/**
      - package-lock.json
  plugins:
    - serverless-webpack
    - serverless-plugin-diff
  </code></pre>
  <p>It compiles and generates the lamdba but, when I try to run a test from AWS Console, I get:</p>
  <pre><code>{
    &quot;errorType&quot;: &quot;Runtime.ImportModuleError&quot;,
    &quot;errorMessage&quot;: &quot;Error: Cannot find module '@sailplane/injector'\nRequire stack:\n- /var/task/src/Functions.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js&quot;,
    &quot;trace&quot;: [
      &quot;Runtime.ImportModuleError: Error: Cannot find module '@sailplane/injector'&quot;,
      &quot;Require stack:&quot;,
      &quot;- /var/task/src/Functions.js&quot;,
      &quot;- /var/runtime/UserFunction.js&quot;,
      &quot;- /var/runtime/Runtime.js&quot;,
      &quot;- /var/runtime/index.js&quot;,
      &quot;    at _loadUserApp (/var/runtime/UserFunction.js:221:13)&quot;,
      &quot;    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)&quot;,
      &quot;    at Object.&lt;anonymous&gt; (/var/runtime/index.js:43:34)&quot;,
      &quot;    at Module._compile (internal/modules/cjs/loader.js:1085:14)&quot;,
      &quot;    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)&quot;,
      &quot;    at Module.load (internal/modules/cjs/loader.js:950:32)&quot;,
      &quot;    at Function.Module._load (internal/modules/cjs/loader.js:790:12)&quot;,
      &quot;    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)&quot;,
      &quot;    at internal/main/run_main_module.js:17:47&quot;
    ]
  }
  </code></pre>
  <p>This is my package.json file:</p>
  <pre><code>{
    &quot;name&quot;: &quot;mavelink-aws&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;Mavelink aws project&quot;,
    &quot;main&quot;: &quot;&quot;,
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;&gt;=14.15.0&quot;
    },
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@types/aws-lambda&quot;: &quot;^8.10.101&quot;,
      &quot;@sailplane/injector&quot;: &quot;^3.0.0&quot;,
      &quot;@sailplane/logger&quot;: &quot;^4.1.0&quot;,
      &quot;aws-sdk&quot;: &quot;^2.1184.0&quot;,
      &quot;zod&quot;: &quot;^3.17.10&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@middy/core&quot;: &quot;^3.1.0&quot;,
      &quot;@middy/http-json-body-parser&quot;: &quot;^3.1.0&quot;,
      &quot;serverless-plugin-diff&quot;: &quot;^3.0.0&quot;,
      &quot;serverless-webpack&quot;: &quot;^5.8.0&quot;,
      &quot;ts-node&quot;: &quot;^9.1.1&quot;,
      &quot;tsconfig-paths&quot;: &quot;^3.9.0&quot;,
      &quot;tsconfig-paths-webpack-plugin&quot;: &quot;^3.3.0&quot;,
      &quot;ts-loader&quot;: &quot;^9.3.1&quot;,
      &quot;typescript&quot;: &quot;^4.7.4&quot;,
      &quot;webpack&quot;: &quot;^5.74.0&quot;,
      &quot;webpack-node-externals&quot;: &quot;^3.0.0&quot;
    }
  }
  </code></pre>
  <p>Any clue? I am using <code>sls deploy</code> command to publish on AWS.</p>