Trying to use Canvas NPM - but it's failing

Hi

I’m trying to use the Canvas NPM package but getting the below error, any idea why?

Are there some NPM libraries that are not supported by JourneyApps Cloudtasks?

09:43:00.981 [INTERNAL:INFO] Created invocation 'T2021111007430...' ...
09:43:00.983 [QUEUE:DEBUG] Adding to queue '580774016564...' ...
09:43:00.986 [QUEUE:INFO] Moved from state 'CREATED' to 'QUEUED'
09:43:01.025 [QUEUE:INFO] Moved from state 'QUEUED' to 'STARTED'
09:43:01.835 [TASK:INFO] Start 'EDITOR_TEST' request. Process trace ID: 'P202111...'. Revision: 'master/draft/4a4757b...
09:43:01.836 [TASK:DEBUG]  {"alg":"RS256","typ":"JWT","kid":"Rg1dhxctp..."} {"iat":1636530181,"exp":1636530781,"jti":"580774016..:text_svg:T202111100743...","iss":"CloudCode/ZA","app":"580774016564..","env":"testing","task":"text_svg","perms":{"https://run-testing.journeyapps.com":["53ce5564..."]},"aud":["cloudcode.journeyapps.com","journeyapps.com"]}
09:43:01.837 [TASK:DEBUG] Raw request: {"method":"POST","headers":{"content-type":"application/json","accept":"application/json","x-journey-token":"ey...","x-journey-trace-id":"3efba7...."},"path":"/5807740165/testing/text_svg","eventSource":"EDITOR_TEST","traceId":"T20211110074300a845c54d","body":"{\"parameters\":null}"}
09:43:01.837 [TASK:ERROR] Error: Cannot find module '../build/Release/canvas.node'
Require stack:
- /var/task/app/cloudcode/text_svg/node_modules/canvas/lib/bindings.js
- /var/task/app/cloudcode/text_svg/node_modules/canvas/lib/canvas.js
- /var/task/app/cloudcode/text_svg/node_modules/canvas/index.js
- /var/task/app/cloudcode/text_svg/index.js
- /var/task/app/cloudcode/text_svg/node_modules/@journeyapps/cloudcode/dist/entry.js
- /var/task/entry.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/var/task/app/cloudcode/text_svg/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Module._compile (/var/task/app/cloudcode/text_svg/node_modules/@journeyapps/cloudcode/node_modules/source-map-support/source-map-support.js:547:25)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
09:43:01.837 [TASK:INFO] Request complete. Response code: 500. Memory used: 50MB.
09:43:01.907 [QUEUE:INFO] Moved from state 'QUEUED' to 'COMPLETED'

CODE

const { createCanvas } = require("canvas");
export async function run() {
    // Your code here

    const width = 1200;
    const height = 620;

    const canvas = createCanvas(width, height);
}

Hi

Unfortunately CloudCode does not currently support installation of anything other than plain JavaScript-based packages. Installing custom binaries or native libraries is not supported, and no post-install scripts of dependencies are run.

So in this case you will need to use a different lib.