SeanSobey / ChartjsNodeCanvas

A node renderer for Chart.js using canvas.
MIT License
228 stars 70 forks source link

Visual Artifact/Glitch in Chart rendered on Node server #125

Open chxpel opened 1 year ago

chxpel commented 1 year ago

I spent 5 hours yesterday debugging the "canvas.node is not a valid win 32 application" bug. This was occurring because I was deploying to a Windows server, but using a pipeline running on Ubuntu.

Then, I had to deal with "Error: The module ...canvas.node'was compiled against a different Node.js version usingNODE_MODULE_VERSION 93. This version of Node.js requiresNODE_MODULE_VERSION 83. Please try re-compiling..."

I managed to fix this by forcing my pipeline to run Node 14 instead of 16.

I've got an Azure DevOps pipeline that deploys a NestJS (Node) app to a Windows server. Part of this app is an API which has an endpoint that renders a chart into a PDF. This works fine locally.

Once I finished fixing this bug and getting my app to deploy, this is what the PDF looks like:

image

This is what the exact same code looks like running locally: image

On my machine, I run Node 12.22.1 For the pipeline, I am using Node 12.22.1 My package.json has chart.js version 3.9.1 and chartjs-node-canvas version 4.1.6

My actual server is running Node 12.21.0

I've tried messing around with versions of node, chartjs, and chartjs-node-canvas, but it is very, very easy to trigger the error "The module was compiled against a different node version...". My best idea so far was to make sure my local machine, pipeline, and deployment server were all running Node 12. I then downgraded both dependencies, but continued receiving the different node version error mentioned above.

Does anyone familiar with this package have any idea why this is happening? It's so weird. This is delaying a very important release.

Also can I post this anywhere else? Not sure if the other canvas related communities can help. I truly am desperate here.