2

I built my own NodeJs Module with node-addon-api in C++ and now I want to use it in an electron.js app. But unfortunetly stuck with can not find module error.

My project structure is like the following:

/
  /build
    /Release
      myAddon.node
  /node_modules
  binding.gyp
  index.js
  index.html
  package.json
  package-lock.json

The node-gyp build runs without failures and the module is in the /build/Release folder.

Now I want to load the module in my index.js file with

const myAddon = require('./build/Release/myAddon.node)

And when I start the app it fails with

Error: Cannot find module 

\\?\Path\To\MyProject\build\Release\myAddon.node

The path in the error message is correct and the .node file is there. Is there any further configuration or setting which I have forgotten?

Here is the output with the bindings addon:

 App threw an error during load
Error: Could not locate the bindings file. Tried:

And then there is a list with some folders it has tried to find it. But none of these folders exists in my project.

pospich0815
  • 378
  • 1
  • 3
  • 13
  • Try to use [bindings](https://www.npmjs.com/package/bindings) to get a better error log. – aabuhijleh Sep 26 '19 at 09:04
  • I have updatet the question with the output – pospich0815 Sep 26 '19 at 10:26
  • In the file tree the file name is called myNodeAddon.node, but in the require line you are referring to it as myAddon.node, maybe it is just that typo. – Guillermo Sep 26 '19 at 15:23
  • No, this is not the Problem. These example has not the real names of the files. I will change this, sorry. – pospich0815 Sep 27 '19 at 06:18
  • did you find the solution? I'm having a same issue but in my case, it works for dev version. however, it threw module not found exception in the production build. Let me know if you have any workaround. – Kiran Maniya Nov 03 '19 at 15:59
  • No, I have no solution for the problem yet. I only had a little discussion here https://github.com/nodejs/help/issues/2207. But there is also no solution. – pospich0815 Nov 05 '19 at 06:56

0 Answers0