# Include dependent js files in a serverless function

**URL:** <https://community.hubspot.com/t/include-dependent-js-files-in-a-serverless-function/120370>\
**Category:** CMS Development\
**Tags:** local-development, javascript\
**Created:** [November 12, 2024, 10:44pm UTC](https://community.hubspot.com/t/include-dependent-js-files-in-a-serverless-function/120370 "2024-11-12T22:44:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FOman](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@FOman](https://community.hubspot.com/u/FOman)\
**Post date:** [November 12, 2024, 10:44pm UTC](https://community.hubspot.com/t/include-dependent-js-files-in-a-serverless-function/120370/1 "2024-11-12T22:44:23Z")

</div>

Hi there! I’m looking to include a dependent js file to a serverless but when I do something like `const urls = require(‘./urls’)` it works locally when I run hs project dev. But after uploading it says it can’t find the file.

Is there something specific to do here to get it working?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [November 13, 2024, 6:24pm UTC](https://community.hubspot.com/t/include-dependent-js-files-in-a-serverless-function/120370/2 "2024-11-13T18:24:54Z")

</div>

Hi, @FOman 👋 Thanks for posting this question. I’d like to invite some of our community experts to the conversation — hey @Teun @JBrake @ChrisoKlepke @Kevin-C, do you have any tips you can share to help get @FOman moving forward?

Thank you for taking a look! — Jaycee

---

<div class="post-metadata">

**Author:** ![JBrake](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbrake/32/76513_2.png) [@JBrake](https://community.hubspot.com/u/JBrake)\
**Post date:** [November 13, 2024, 7:26pm UTC](https://community.hubspot.com/t/include-dependent-js-files-in-a-serverless-function/120370/3 "2024-11-13T19:26:11Z")

</div>

Oh yes, I’ve come across this before. I think you you need to create your code as a package and use require like you do for axios or request. Then build/bundle the file to upload to HS.  
I’ve not done this for my own code (yet, but have reasosn to in the future), but have for unsupported packages in HS like stripe and encryption. I think the approach would the same.  
Im not a node developer per se so wont go into the technical aspects of doing it. (a.k.a. I needed help setting this up and get running by someone more knowledgeable of such things.) Do you know any node developers that might help?  
Jonathan

---

<div class="post-metadata">

**Author:** ![FOman](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@FOman](https://community.hubspot.com/u/FOman)\
**Post date:** [November 14, 2024, 6:45pm UTC](https://community.hubspot.com/t/include-dependent-js-files-in-a-serverless-function/120370/4 "2024-11-14T18:45:47Z")

</div>

Cool, yeah I was thinking along the same lines. I tried out including the file in the package.json. It didn’t work the way i wanted but maybe it is along those lines. I’ll update if I have anything, or hopefully someone konws the solution!
