I had this problem for a electron-vite project
What I had to understand was that
- electron comes with its own node_module_version
- node comes with its own node_module_version
Even though :
- electrons node version also 20.16
- my local node version also was 20.16
The node "module" version were still different 125(electron) and 115(node)
Now the tricky part is that in development my electron environment is run on Node(node command) and in packaged production it is run on electron ( electron command)
So what i had to do was have 2 versions of my native modules
- development modules that were compiled against my node version ( I used node-gyp for that)
- production modules that were compiled against my electron version ( i used electron rebuild for that) but node-gyp theoretically can be used as well since you can define target and architecture..