1

I am trying to deploy an AzureFunctions in NodeJs but it doesn't work on Azure. My apllication is a v3 functions running on Linux.

When the deploy is completed, i get this 500 error:

Error: /home/site/wwwroot/node_modules/canvas/build/Release/canvas.node: invalid ELF header

Its happen only when I do this imports:

 import ChartDataLabels from 'chartjs-plugin-datalabels';
 const canvasRenderService = new CanvasRenderService(width, height, chartCallback);

 const chartCallback = (ChartJS) => {
     ChartJS.register(require('chartjs-plugin-datalabels'))
 };
 const jsdom = require("jsdom");
 const { JSDOM } = jsdom;
 const { document } = (new JSDOM(`...`)).window;

Would someone help me please?

It works (only) on my machine :(

Edit: It works when I make the deploy by Linux Subsystem. I hope this will help somebody.

  • ELF is an executable program format. You have a program/binary compiled for the wrong architecture. I do not use canvas, so I cannot advise further. https://www.npmjs.com/package/canvas – John Hanley Nov 26 '21 at 01:10

2 Answers2

0

Azure function will not include the Node_modules while deploying into azure. Because Node_modules directory contains very large file. You can include your package.json in you function directory and run npm install as you normally would with Node.js projects using Kudu (https://<function_app_name>.scm.azurewebsites.net )or the Console in the Azure portal.

Check Dependency management for more information.

Refer here Link 1 & Link 2

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15
0

Any updates on this topic? Doesn't seem like a valid option for me to manually run npm install via KUDU or some other terminal in a Cloud Function App - especially with Continoues Deployment etc.

Got the same problem while using canvas for barcode generation...

Andreas Rainer
  • 314
  • 4
  • 16