APIs & Integrations

DavidFJones
Member | Platinum Partner
Member | Platinum Partner

Severless Function API "Module not found : Express"

SOLVE
Hey all,I'm running into an issue with express and serverless functions. When I try to make an api call with my serverless function I get the following error
"Cannot find module 'express'
I was pretty sure that I had installed the dependencies correctly through my package.json and package-lock.json files, but I'm still quite new to using api's/serverless functions

Thanks
0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Severless Function API "Module not found : Express"

SOLVE

Hey @DavidFJones,

 

I believe my colleague Derek has been helping you out with this case on our developer slack channel and I'd like to update this case here for other users reference:

 

tl;dr

With serverless function, you do not need the `express` module. You only need to write the specific code you'd like to execute. HubSpot manages defining the endpoint, accepting requests and sending the response to the client for you. 

View solution in original post

0 Upvotes
3 Replies 3
WendyGoh
HubSpot Employee
HubSpot Employee

Severless Function API "Module not found : Express"

SOLVE

Hey @DavidFJones,

 

Could you try installing the express module like this:

 

 npm install express

and see if it works?

0 Upvotes
DavidFJones
Member | Platinum Partner
Member | Platinum Partner

Severless Function API "Module not found : Express"

SOLVE

Hey @WendyGoh , so I've tried running that command both on my parent directory and the actually theme directory but I am still getting the same error when I attempt to run.

For reference my current local setup is a parent folder with the yml and node_modules folder, then I have a subdirectory that actually includes my theme and all associated files for it.

0 Upvotes
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Severless Function API "Module not found : Express"

SOLVE

Hey @DavidFJones,

 

I believe my colleague Derek has been helping you out with this case on our developer slack channel and I'd like to update this case here for other users reference:

 

tl;dr

With serverless function, you do not need the `express` module. You only need to write the specific code you'd like to execute. HubSpot manages defining the endpoint, accepting requests and sending the response to the client for you. 

0 Upvotes