Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions - Import Custom Node Module

I'm experimenting with Azure Functions. I'm trying to use a third-party Node module in my function. However, I've been unable to figure out how to import it.

{
  "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "requestId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "statusCode": 500,
  "errorCode": 0,
  "messsage": "Exception while executing function: Functions.analyze -> Error: Cannot find module 'moment'\n    at Function.Module._resolveFilename .."
}

I'm just trying to import the moment.js Node library. I was unable to find any documentation around this scenario though.

Does anyone know how to import a third-party module into Azure Functions?

like image 714
user687554 Avatar asked Jun 14 '26 21:06

user687554


1 Answers

  1. In your function app in the Azure portal, click Platform features and Advanced tools (Kudu).

enter image description here

  1. cd into your function directory via Debug console (CMD or PowerShell) and run the command: npm install moment.

enter image description here

like image 121
Aaron Chen Avatar answered Jun 16 '26 13:06

Aaron Chen