Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with Node v18.12.1 and Electron v21.0.1 getting the Error: Compiled against a different Node.js version using NODE_MODULE_VERSION 108. The version of Node.js requires NODE_MODULE_VERSION 109. #2156

Closed
1 task done
GitMurf opened this issue Nov 7, 2022 · 8 comments

Comments

@GitMurf
Copy link

GitMurf commented Nov 7, 2022

Issue or Feature

As the title says, I am getting the error: Compiled against a different Node.js version using NODE_MODULE_VERSION 108. The version of Node.js requires NODE_MODULE_VERSION 109.

I know this has been discussed many times in the past but I have tried all the suggested solutions and have read all of the applicable GitHub Issues, installation guides etc. and no luck.

image

Steps to Reproduce

In my hello world Electron app I simply have the following at the top and it gives the error.

const { createCanvas, loadImage } = require('canvas');

Your Environment

  • Version of node-canvas: 2.10.2
  • Environment: Node 18.12.1 + Electron 21.0.1 + Windows 11

I am simply using the current LTS version of Node (18.12.1) as well as the current Stable version of Electron (21.0.1).

@GitMurf
Copy link
Author

GitMurf commented Nov 7, 2022

I had looked at #2132 which said it was closed in favor of a duplicate here: #2025 which then was closed out based on this comment saying that Node v18 and v19 should now be supported with Canvas v2.10.2 here: #2025 (comment)

@LinusU
Copy link
Collaborator

LinusU commented Nov 8, 2022

NODE_MODULE_VERSION 108 is Node.js 18.x, and Node.js 19.x is 111.

Which version are you using, that requires 109? 🤔

ref: https://nodejs.org/en/download/releases/

edit: just saw in the title that you are using electron, this is not something that we support right now, but if there are instructions on how to make it work we'd be happy to add it

seems like maybe electron-rebuild is a tool that could be used? #1789

@LinusU LinusU closed this as completed Nov 8, 2022
@GitMurf
Copy link
Author

GitMurf commented Nov 10, 2022

@LinusU thank you for the quick reply. I have tried electron-rebuild but am having issues with it getting node-gyp errors. See here: electron/rebuild#1042

I know you cannot answer for Electron-rebuild but curious if these errors in my referenced Issue make any sense to you given your experience with native node modules? Thanks!

@GitMurf
Copy link
Author

GitMurf commented Nov 10, 2022

  1. Also @LinusU is it odd that Electron is using NODE_MODULE_VERSION 109 when it isn't even listed in node.js releases?
  2. Because node-canvas doesn't have a prebuilt for 109 does that make it virtually impossible for us to make it compatible with Electron at this point?

@GitMurf
Copy link
Author

GitMurf commented Nov 11, 2022

edit: just saw in the title that you are using electron, this is not something that we support right now, but if there are instructions on how to make it work we'd be happy to add it

@LinusU after further troubleshooting I was finally able to get node-canvas to work with Electron with some workarounds. But after deep diving into several different issues along the way, and now finally running into a crash using node-canvas getting the error [7088:1111/085132.471:ERROR:crashpad_client_win.cc(844)] I have been led to believe that there are several issues with node-canvas relying on nan. Below are some of the key issues / explanations I have gathered from elsewhere.

cmake-js/cmake-js#222 (comment)
#1868 (comment)
nodejs/nan#922 (comment)
electron/electron#29893
#1868 (comment)

Is this something you have looked into / thought about? (switching away from usage of nan)
Any advice?

Thanks!

@GitMurf
Copy link
Author

GitMurf commented Nov 24, 2022

@LinusU here (nodejs/nan#892 (comment)) is another good explanation of the issue. It seems the issue is using nan instead of node-api (napi). Is this something you all would consider? This is a huge problem because of how popular Electron is getting and because so many packages / libraries depend on node-canvas (like pdf.js).

Thanks in advance! I have been trying to figure out a workaround for weeks now and no luck and I see a bunch of chatter from others with same issues.

@GitMurf
Copy link
Author

GitMurf commented Nov 24, 2022

Also see here: nodejs/nan#922 (comment)

@DarkSynx
Copy link

do not neglect : npx electron-builder install-app-deps
a different version may be compiled without your consent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants