3

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?

Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
user687554
  • 10,663
  • 25
  • 77
  • 138
  • 2
    Possible duplicate of [How can i use package management in NodeJS Azure Functions?](https://stackoverflow.com/questions/36461247/how-can-i-use-package-management-in-nodejs-azure-functions) – Mikhail Shilkov Jul 18 '17 at 14:13

2 Answers2

6
  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

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
0

This is now out of date. Instead, go to Advanced Tools (Kudo) -> Bash -> cd site/wwwroot -> npm i package

A. Wentzel
  • 484
  • 8
  • 16