DieMantraD
Convex Community9mo ago
2 replies
DieMantra

Nodejs canvas in actions.

Are we not allowed to use packages like: https://www.npmjs.com/package/canvas ?
It has native bindings to what looks like python.
I tried precompiling it in docker container and just chucking the canvas package inline in a _vendor folder in ./convex... that also didn't work.
I tried adding it to externalPackages:
{
  "node": {
    "externalPackages": [
      "canvas"
    ]
  }
}

My action just looks like this:
'use node';

import { action } from '@convex/_generated/server';
import { createCanvas } from 'canvas';

export const checkServerArchitecture = action({
    args: {},
    handler: async (ctx, args) => {
        console.log('Platform:', process.platform);
        console.log('Architecture:', process.arch);
        console.log('Node.js Version:', process.version);
        const canvas = createCanvas(200, 200);
        return 'ok';
    },
});
npm
Canvas graphics API backed by Cairo. Latest version: 3.1.0, last published: 4 months ago. Start using canvas in your project by running npm i canvas. There are 2899 other projects in the npm registry using canvas.
canvas
Was this page helpful?