electron-webpack-quick-start icon indicating copy to clipboard operation
electron-webpack-quick-start copied to clipboard

How to add a custom made native dependency

Open BiancoA opened this issue 8 years ago • 2 comments

I am looking for some documentation on how to add a native dependency. I created an example here https://github.com/BiancoA/electron-webpack-quick-start-nm and asked a https://stackoverflow.com/questions/46930628/attempting-to-link-a-native-module-using-electron-webpack stackoverflow question.

I compiled my .node module using node-gyp and now I would like to use it from electron, but I get:

  Error: Cannot find module 'mymoduleND'
      at Module._resolveFilename (module.js:470:15)
      at Function.Module._resolveFilename (/Users/bianco/Src/electron-webpack-quick-start-nm/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
      at Function.Module._load (module.js:418:25)
      at Module.require (module.js:498:17)
      at require (internal/module.js:20:19)
      at eval (webpack-internal:///mymoduleND:1:18)
      at Object.mymoduleND (/Users/bianco/Src/electron-webpack-quick-start-nm/dist/main/main.js:748:1)
      at __webpack_require__ (/Users/bianco/Src/electron-webpack-quick-start-nm/dist/main/main.js:655:30)
      at fn (/Users/bianco/Src/electron-webpack-quick-start-nm/dist/main/main.js:65:20)
      at Object.eval (webpack-internal:///./src/main/index.js:4:69)

some help or some documentation? Thanks!

BiancoA avatar Oct 26 '17 15:10 BiancoA

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 someone wants to review it and check if there are other possible ways, or correct any mistake I probably made, I'd be more than happy

BiancoA avatar Oct 27 '17 15:10 BiancoA

I believe using yarn link is a required step to make this work and should do what you need it to.

SimulatedGREG avatar Nov 05 '17 00:11 SimulatedGREG