1

I'm new into webpack, and I'm having an issue trying to resolve a subdependency.

I'm importing a dependency that is trying to require a module from a specific folder (not the node_modules) (let's call it subdependency). That folder contains two files:

subdependency/package.json

subdependency/build/Release/addon.node

subdependency/lib/src/index.js (this index.js requires the addon.node)

I'm using webpack, and when importing my dependency it was not able to find subdependency.

The subdependency is there but it was not accessible. I added a loader for loading .node files https://www.npmjs.com/package/native-ext-loader and it was still not working; trying to identify what was happening I modified in my build the require path from ./subdependency to ./subdependency/build/Release/addon.node and the file was accessible (so I guess the native ext loader is working fine, but it's not loading other files like the index.js).

I think the problem is that webpack is not able to understand that ./subpdendency is a module, or that I'm not loading it correctly.

Any suggestion or idea is welcome!

caraie
  • 1,094
  • 7
  • 18
  • [roothpath](https://www.npmjs.com/package/rootpath) may help... – Hary Aug 06 '19 at 13:15
  • thanks for the answer mbharanidharan88, the require is in the dependency, not in my code, but I think the relative path is being handled correctly, but not loaded correctly (./subdependendcy and the files are there, and the require looks like it's pointing to the correct folder but it's not able to load and understand that the index.js needs to be fetched). Thanks anyway for the suggestion! – caraie Aug 06 '19 at 13:27

1 Answers1

0

I resolved the issue by forking the dependency and switching from node-pre-gyp to prebuildify, since node-pre-gyp doesn't works fine with webpack.

caraie
  • 1,094
  • 7
  • 18