I wrote a native module in c++ using the v8.h headers and I want to import it in my electron app.
The module works fine. I compile it in it's own folder, then I copy-paste the .node into this boilerplate https://github.com/szwacz/electron-boilerplate and I require it using the bindings
package.
I would like to use this https://github.com/electron-userland/electron-webpack-quick-start as a starting point to build my electron application. Mainly for two reasons: it is the recommended way and it promises to package your app for macos, linux and windows. I copied the folder containing the source code inside the root folder of the project, I added the bindings.gyp
file and "nodeGypRebuild": "true",
to the package.json
in the root folder. The module is compiled with yarn install
but if I try to import it import {Module} from 'MyModule'
in src/main/index.js
and run yarn dev
the output is
Module not found: Error: Can't resolve 'MyModule' in '/Users/BiA/Src/WebPack/src/main'
While googling the problem I landed here https://github.com/chentsulin/electron-react-boilerplate/wiki/Module-Structure----Two-package.json-Structure and now I am even more confused, since there is no app/
folder in electron-webpack-quick-start
Can someone help me finding a way to exit from this dead end? Does it exist a documentation that covers this case? Even a working example, like an open source project where I can lear to do this would help.
edit: to better understand the problem I created a simple git repository: https://github.com/BiancoA/electron-webpack-quick-start-nm
I found a solution to the problem using yarn link
: https://yarnpkg.com/lang/en/docs/cli/link/
here I saved the working project: https://github.com/BiancoA/electron-webpack-quick-start-nm
If there are other possible ways, I'll be happy to learn them