# Error cannot find module after deploying Cron app

**URL:** <https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [September 14, 2022, 5:36pm UTC](https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614 "2022-09-14T17:36:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahovingh2](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@ahovingh2](https://forum.serverless.com/u/ahovingh2)\
**Post date:** [September 14, 2022, 5:36pm UTC](https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614/1 "2022-09-14T17:36:50Z")

</div>

After I deploy, I get the message “Error: Cannot find module ‘axios’” . This will run locally, and I have run npm install in the root directory. I’m not sure why it’s not coming over to AWS even though it’s in the package.json file. Below is a screenshot of the code and the file structure. Below that is the package.json file that I’m deploying with.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/0/002ba786c0b4b0a0fa15b0b4c54a69b451faec7c.png)

![image](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/f/f0c8e00765f7c0c8765ea2aea31f78ea3b1c882d.png)

---

<div class="post-metadata">

**Author:** ![ktwbc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ktwbc/32/764_2.png) [@ktwbc](https://forum.serverless.com/u/ktwbc)\
**Post date:** [September 15, 2022, 1:38am UTC](https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614/2 "2022-09-15T01:38:37Z")

</div>

Packages are included because they are found in import statements. Are you using older require() or es6 style imports (es6 works better).

Also you’re showing typescript in dev dependencies but all your files are .js. Are you using typescript?

---

<div class="post-metadata">

**Author:** ![ahovingh2](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@ahovingh2](https://forum.serverless.com/u/ahovingh2)\
**Post date:** [September 15, 2022, 3:46pm UTC](https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614/3 "2022-09-15T15:46:17Z")

</div>

I was going to phase in typescript, but I don’t have it in right now. I tried it without the typescript requirement with the same result. That being said, I am using older require statements. I’ll go ahead and use imports instead to see if that helps.

---

<div class="post-metadata">

**Author:** ![ahovingh2](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@ahovingh2](https://forum.serverless.com/u/ahovingh2)\
**Post date:** [September 19, 2022, 1:09pm UTC](https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614/4 "2022-09-19T13:09:15Z")

</div>

The problem I’m having with this approach is the fact that the built-in function deployed with serverless uses a require statement.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/4/42fb1f8e3c877b978415ee9913cf2e8b0410e113.png)

I cannot use this when I add  
“type”: “module”  
To the package.json file to support import statements. Also, I’ve tried changing this to an import statement, and I get the error:  
The requested module ‘./serverless\_sdk/index.js’ does not provide an export named ‘serverlessSDK’"

---

<div class="post-metadata">

**Author:** ![ahovingh2](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@ahovingh2](https://forum.serverless.com/u/ahovingh2)\
**Post date:** [September 21, 2022, 1:16pm UTC](https://forum.serverless.com/t/error-cannot-find-module-after-deploying-cron-app/17614/5 "2022-09-21T13:16:24Z")

</div>

I found the root cause of this. I’ve been using serverless-plugin-include-dependencies to deploy my functions as the npm libraries with the solution has grown to a point that it won’t deploy without it. In certain environments, the latest version (version 5 at the time of this) doesn’t deploy any dependencies. I rolled back the version to 4.1 and it seemed to work.  
Also note, that it took about 8 or 9 minutes to deploy and it looked like it froze, but did eventually work, so if anyone else is reading this and runs into this, I hope I’ve just saved you hours worth of time.
