Skip to content
← Back to Community
npm package canvas not working
Profile icon
Theix

As the title says I'm trying to use the canvas package. But when I run the code It gives me this:

Error: The module '/home/runner/HvadErDetNuDetHedder/node_modules/canvas/build/Release/canvas.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 83. This version of Node.js requires NODE_MODULE_VERSION 72. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`). at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.<anonymous> (/home/runner/HvadErDetNuDetHedder/node_modules/canvas/lib/bindings.js:3:18) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14)

I expected it was because the canvas package was newer, and because replit uses an older version node.js it doesn't work. I somehow fixed this isue once, and got it to work, but I have no idea what I did, and cannot get it to work now. I know [email protected] should match the version of node replit uses. Any help is much appreciated

Voters
Profile icon
FaridAbbasbayli
Profile icon
Theix
Comments
hotnewtop
Profile icon
Theix

Nvm I fixed it by using yarn to install [email protected] and just updated the package.json to say "canvas": "^2.8.0". And now it works