1

I'm currently using chartjs-node to generate some charts. My node.js code runs perfectly on my local (windows) machine, but I suspect that's because I have windows-build-tools installed, which includes the cairo package.

When I push to my remote (linux) server and try to compile, I get the following error:

No package 'cairo' found

However, my package dependency list is as follows:

"canvas-prebuilt": "^1.6.5-prerelease.1",
"chart.js": "2.6.0",
"chartjs-node": "^1.6.1"

Based on my understanding from the documentation, using canvas-prebuilt instead of canvas should circumvent the need for any package pre-installation on my server. Obviously, I could just preinstall the necessary packages (as described in this SO answer) - but I'm wondering if there's any way to set up my package dependency list to avoid that route.

Thanks for your help!

CaptainPlanet
  • 352
  • 2
  • 13

1 Answers1

3

You could switch chartjs-node to my chartjs-node-canvas package. It uses canvas-prebuilt instead of canvas, one of the main reasons for its existance :)

Sean Sobey
  • 942
  • 7
  • 13
  • Aha! I wish I had seen this earlier; I ended up just switching to using [node-highcharts-exporting](https://www.npmjs.com/package/node-highcharts-exporting), which has a bit uglier charts, but at least is completely prebuilt. But thanks for the response! – CaptainPlanet May 03 '18 at 17:30