title: Unable to upload npm dependencies on AWS Lambda Layer
body: <p>I have a .zip file, which contains node_modules and a utils folders,<br>
  I upload the .zip on AWS Lambda Layer, but I am unable to fetch all the dependencies on the AWS Lambda function,<br></p>
  
  <p>I believe the issues could be about the package.json, but<br> 
  I tried deleting the node_modules, package-lock.json and reinstalling the dependencies using <code>npm install</code> command.<br>
  The dependencies seem to be downloaded on local but, when I upload them on Layers, they just disappear.</p>
  
  <p><strong>Root folder -</strong>
  <a href="https://i.stack.imgur.com/lrIxG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lrIxG.png" alt="enter image description here"></a></p>
  
  <p><strong>Sub directories under layer folder -</strong>
  <a href="https://i.stack.imgur.com/AATcK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AATcK.png" alt="enter image description here"></a></p>
  
  <p><strong>node_modules -</strong>
  <a href="https://i.stack.imgur.com/LZnmW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LZnmW.png" alt="enter image description here"></a></p>
  
  <p><strong>package.json-</strong></p>
  
  <pre><code>{
    "name": "serverless-currency",
    "version": "1.0.0",
    "description": "Lambda APIs for G2G Currency Module",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1",
      "debug": "SLS_DEBUG=* sls offline start"
    },
    "author": "Aniruddha Raje",
    "license": "ISC",
    "dependencies": {
      "async": "^2.6.2",
      "aws-sdk": "^2.447.0",
      "axios": "^0.18.0",
      "cryptr": "^4.0.2",
      "jsonwebtoken": "^8.5.1",
      "moment": "^2.24.0",
      "serverless-offline": "^4.9.4",
      "util": "^0.12.0"
    }
  }
  </code></pre>
  
  <p><strong>AWS Lambda code -</strong></p>
  
  <pre><code>var fs = require('fs');
  var async = require('async');
  
  exports.handler = async (event) =&gt; {
  
      const testFolder = '/opt/layer/node_modules';
  
      fs.readdirSync(testFolder).forEach(file =&gt; {
    console.log(file);
  });
  };
  </code></pre>
  
  <p><strong>Lambda error -</strong></p>
  
  <pre><code>{
    "errorMessage": "Cannot find module 'async'",
    "errorType": "Error",
    "stackTrace": [
      "Function.Module._load (module.js:474:25)",
      "Module.require (module.js:596:17)",
      "require (internal/module.js:11:18)",
      "Object.&lt;anonymous&gt; (/var/task/index.js:2:13)",
      "Module._compile (module.js:652:30)",
      "Object.Module._extensions..js (module.js:663:10)",
      "Module.load (module.js:565:32)",
      "tryModuleLoad (module.js:505:12)",
      "Function.Module._load (module.js:497:3)"
    ]
  }
  </code></pre>
  
  <p><strong>Reference -</strong><br>
  <a href="https://medium.com/@anjanava.biswas/nodejs-runtime-environment-with-aws-lambda-layers-f3914613e20e" rel="nofollow noreferrer">https://medium.com/@anjanava.biswas/nodejs-runtime-environment-with-aws-lambda-layers-f3914613e20e</a><br></p>
  
  <p>Is it mandatory to name the root folder as <code>nodejs</code> so the node_module libs could be directly accessed using the <code>let async = require('async')</code> import,<br>
  So that the code doesn't need to specify the /opt/node_modules/async path?<br>
  The code ran without error when specified the absolute path.</p>