'Javascript doesn't run with both electron and canvas libraries installed

I'm trying to use electron and canvas in the same script, but it throws an error when I try. I've tried using canvas and electron separately with the same node version and they worked perfectly fine. Here is the error I am getting

Error: The module '\\?\C:\Users\tomow\OneDrive\Desktop\code\Applications\NFT-Generator\node_modules\canvas\build\Release\canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 102. This version of Node.js requires
NODE_MODULE_VERSION 89. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1846)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1138:18)
    at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1846)
    at Module.load (internal/modules/cjs/loader.js:935:32)
    at Module._load (internal/modules/cjs/loader.js:776:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Users\tomow\OneDrive\Desktop\code\Applications\NFT-Generator\node_modules\canvas\lib\bindings.js:3:18)
    at Module._compile (internal/modules/cjs/loader.js:1078:30)```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source