Reputation: 65
I've started an ElectronJS/React/Typescript project including the pcap module. Unfortunately, this module requires a native dependency (pcap_binding.node).
I've already overridden the webpack configuration using react-app-rewired
by creating the file config-overrides.js
.
So far, I tried the following loaders: native-ext-loader
, @marshallofsound/webpack-asset-relocator-loader
, @zeit/webpack-asset-relocator-loader
, and node-loader
.
Epic fail. I still got the error:
Module not found: Error: Can't resolve './build/Release/pcap_binding' in '/mnt/Data/Dropbox/DTI/Developement/asterix_flux_transporter/node_modules/pcap'
My Electron web preferences are:
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true
}
and I also override webpack configuration with target: "electron-renderer"
.
Og course, if I use the same code on terminal without ElectronJS, that is to say only NodeJS, everything is running fine...
How can I get rid of that error? Thanks for your help!
Upvotes: 0
Views: 103
Reputation: 183
You can use native node moudles using electron, you just need to make the calls from the main process and communicate with the frontend. Read about Inter-Process Communication in electron.
Upvotes: 1