title: Unable to import module 'handler' aws lambda function in nodejs
body: <p>I keep getting this error and I don't know what is causing it.</p>
  
  <p>I am having an API that based on a condition will post to another API, 
  but I get this error in my wrapping API.</p>
  
  <p>Here is the code ...</p>
  
  <p><strong>handler.js</strong></p>
  
  <pre><code>'use strict';
  const axios = require('axios');
  
  module.exports.thumbnailWrapperAPI = (event, context, callback) =&gt; {
  
  
    const incomingData = JSON.parse(event.body);
    if(incomingData.source.includes('png') || incomingData.source.includes('jpg')){
      const newLocal = 'some endpoint...';
      // call image resizing API...
      axios.post(newLocal,{
        source: incomingData.source,
        target: incomingData.target,
        width: incomingData.width
      })
      .then(response =&gt; callback(null,response))
      .catch(error =&gt; callback(error))
  
    } else if(incomingData.source.includes('html')) {
      // handle HTML
    } else {
      //...
    };
  };
  </code></pre>
  
  <p><strong>serverless.yaml</strong></p>
  
  <pre><code>service: thumbnailWrapperAPI 
  provider:
    name: aws
    runtime: nodejs8.10
    region: eu-west-1
  
  functions:
    thumbnailWrapperAPI:
      handler: handler.thumbnailWrapperAPI
      events:
        - http:
            path: generatethumbnail/
            method: post
            cors: true
  </code></pre>
  
  <p>Any advice would be appreciated.</p>
  
  <p><strong>ERROR MESSAGE:</strong></p>
  
  <pre><code>Unable to import module 'handler': Error
      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.&lt;anonymous&gt; (/var/task/handler.js:2:15)
      at Module._compile (module.js:652:30)
      at Object.Module._extensions..js (module.js:663:10)
      at Module.load (module.js:565:32)
      at tryModuleLoad (module.js:505:12)
      at Function.Module._load (module.js:497:3)
  </code></pre>