• [Wébinaire 13 novembre 2025] Comment l’IA optimise la performance marketing in HubSpot ?

    S'inscrire

CMS Development

MAsghari
Participant | Partenaire solutions Elite
Participant | Partenaire solutions Elite

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi There,

I'm deploying a custom UI Extension in HubSpot that includes serverless functions. Locally, everything works fine, but once I deploy, I encounter the following error:

 

 

{
    "status": "error",
    "message": "The serverless function 'handle-report' failed to execute: Cannot find module './services/handle-report-service'\nRequire stack:\n- /var/task/test.js\n- /var/task/hubspotHandler.js\n- /var/runtime/index.mjs."
}

 

 

I'm attempting to require a local module from in 'handle-report' which is a serverless function:

 

 

// Services
const HandleReportService = require('./services/handle-report-service');

exports.main = async (context = {}) => {
  -----
}

 

In local development, this works perfectly, and the module is found as expected. However, once the extension is deployed in the HubSpot environment, using 'hs project upload' the serverless function fails with a "Cannot find module" error.

 

What I've Tried:

  1. Using Relative Paths (./services/handle-report-service😞

  2. Using path.join() and path.resolve() with __dirname:

  3. Testing process.cwd():

  4. Double-checking the folder structure:

    • The services/handle-report-service.js file is present locally and is deployed as part of the extension.
  5. Checking deployment settings and logs:

    • I reviewed the deployment logs, but nothing indicates why this file isn't being found.

 Can you help me to understand the problem?

0 Votes
11 Réponses
LauraMarie
Participant

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

What platform version are you using? Remember that version 2025.2 does NOT handle serverless functions. Make sure you're using 2025.1

 

0 Votes
craigjacksonids
Membre

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Sorry to bother, I know it has been a while but I am chasing this issue myself. Did you find a solution?

0 Votes
chighsmith
Gestionnaire de communauté
Gestionnaire de communauté

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi @craigjacksonids,

Thank you for posting to the Community! 

It doesn't look like we've found a solution to this yet; however, let's tag in some Top Contributors to see if they have any ideas -- Hi @LauraMarie @ArisudanTiwari and @kosalaindrasiri. Do you have any suggestions?

Thank you!

Cassie, Community Manager

 

 





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




LauraMarie
Participant

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

What platform version are you using? Remember that version 2025.2 does NOT handle serverless functions. Make sure you're using 2025.1

0 Votes
craigjacksonids
Membre

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi,
Thanks for your response.

It is 2025.1 but I eventually found a hubspot article saying the local
includes are not supported with Hubspot's serverless functions so I just
have to cut and paste common routines into each function

Cheers,
Craig
0 Votes
MAsghari
Participant | Partenaire solutions Elite
Participant | Partenaire solutions Elite

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi There!

Any feedback/solution for  this?

 

0 Votes
MAsghari
Participant | Partenaire solutions Elite
Participant | Partenaire solutions Elite

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi @kennedyp 

Can you please check this question and send it to one your specialist to check!

I'd appreciate if @zach_threadint can take a look at this!

0 Votes
kennedyp
Gestionnaire de communauté
Gestionnaire de communauté

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Thanks for the tag, @MAsghari! I want to invite some subject matter experts to see if they have any suggestions.

Hey @danmoyle, @Mike_Eastwood , @Teun do you have any thoughts on this?


loop Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.
Learn More

0 Votes
MAsghari
Participant | Partenaire solutions Elite
Participant | Partenaire solutions Elite

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi @kennedyp  Can you please check if anyone has an answer for this? I keep receiving this error for multiple projects and have no idea how to fix it. The provide answers up to now are not correct! 

0 Votes
KhushbooP11
Participant

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi @MAsghari,

The issue likely stems from how HubSpot handles paths in the serverless environment after deployment. In a serverless setup, the directory structure may differ from local development, so relative paths don't always behave as expected.

Here’s what you can do:

1. Check that the filename and the import path match exactly, including case sensitivity. Serverless environments may be stricter about this than local ones.


2. Try switching from relative paths (./services/handle-report-service) to absolute paths by using path.resolve() to ensure the correct module path:

const path = require('path');
const HandleReportService = require(path.resolve(__dirname, './services/handle-report-service'));

3. Verify that the services/handle-report-service.js file is included in the build when you deploy the project using hs project upload. Sometimes, files may not be uploaded if excluded in deployment settings.


4. If the issue persists, try cleaning the project (delete build artifacts) and re-deploying it using hs project upload.

This should help resolve the path issue in the serverless environment.

 

I hope it helps, let me know if you need to talk!

Khushboo Pokhriyal

Growth & Operations

GroRapid Labs

LinkedIn | 9315044754 | Email | Website



0 Votes
MAsghari
Participant | Partenaire solutions Elite
Participant | Partenaire solutions Elite

HubSpot UI Extension | Serverless Function Fails to Find Local Module After Deployment in HubSpot UI

Hi, Thanks for your response,

I Already tried all of them, none of them will work!

0 Votes