-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
better-sqlite3 was compiled against a different Node.js version #545
Comments
Mocha needs to use |
i am getting same error too |
I haven't tested the workaround which @Prinzhorn suggested. I tried to implement e2e as a workaround. But since I am using react it is no fun with Spectron. |
Like @Prinzhorn pointed out, the issue is that
This should show the version of the With this you can also run your tests, I'm for example running my
The |
Hi, I was having the same issue, I already posted a solution here: #126 (comment). Let me know if it works for you. Still works on |
@simeon9696 As @snake-py mentioned, it is an issue when using the test suite: "However I have the problem when I am trying to run a test suit." The rebuilding you suggest actually already works properly. And that is exactly is causing the issue in the first place, because it is being rebuild for the This means you need to run the test suite using the Ugly solution is to rebuild |
@pepijnverburg I have the same issue with Jest, I don't understand what you recommend to do. Do you recommend to execute in command line Note that I use electron forge webpack typescript boilerplate, |
@ambroiseRabier I'll try to explain it more clearly ;) Because you need both Okay, let me start from the beginning (yes, this requires some reading). (1) Understanding different NodeJS versionsSo we know that For example So, now you have a (2) Running tests via the CLIBut... Now we want to write some tests that we run using Well, because you want to run the tests outside of Electron it needs to use the NodeJS version of your system. Chances are high that the NodeJS version you have on your system is different than the one used by Electron internally. For example I have several Electron apps still running This makes it impossible for the (3) Using Electron internal NodeJS versionNow Electron has made a nice environment variable that you can run any command using the NodeJS version used by your Electron version. This variable is: I would suggest you to try these two commands to see that the NodeJS versions are different. To get your system-wide NodeJS version: node --version Now let's get the NodeJS version your Electron installation: ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron --version You will see two different versions that confirm that the The solution that I proposed above is that you run your node ./node_modules/jest-cli/bin/jest.js (4) THE FIXBut in this case we don't want the system-wide NodeJS version, but the one Electron uses. So, as seen above to do this you can type ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/jest-cli/bin/jest.js Hope this clears it up for you. Let me know! |
@pepijnverburg Thanks for taking the time to make a detailed explanation. I think I understand it right. I suppose that But I still got the error The error went away using the command line you provided. Indicating that |
@ambroiseRabier No problem, good to hear this fixed your issue. Looking briefly at those boilerplates and Electron Forge I think you are right; that makes this issue even more confusing as the rebuild happened without your knowledge 😃. @JoshuaWise You can probably close this issue now as it seems quite clear what causes it and how to solve it. |
I found this issue while using the electron-forge webpack template. I resolved it by lowering the electron package version to 12.0.2 and the electron-forge packages to ^6.0.0-beta.54. |
I am getting these errors even without Electron/Mocha... Here is the list of dependencies in package.json:
|
In case anyone is facing this issue for any other executable (such as
#!/usr/bin/env node So you just need to prepend your ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/.bin/mocha ./**/test.js instead of |
Hi, better_sqlite3.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 106. The strange is that 106 non exist in the Node history.... anyway I use vitest to make test and I have follow your advice: do you have any other suggest? |
what is the solution to this if you are not using electron? |
I think I solved it just by reinstalling the package. |
ah that worked thx |
I tried reinstalling abt 5 times now. And still nothing. It tells me it needs Version 93. I have Version 120 |
Hey,
I am trying to integrate unit testing using mocha, my app is running fine. However, when I try to import any module which uses better-SQLite I get this error:
I cloned my project and rebuild it. But I still have the same error. This seems kind of related to #211 However I have the problem when I am trying to run a test suit. The app is running fine in production as well as in dev mode. But for the next steps, I need to implement some unit testing.
The command I ran
So the thing is when I rebuild against plain node my tests start running, however, then my app fails to run.
The text was updated successfully, but these errors were encountered: