tidepool-org / node-mtp

Access devices over MTP using Node.js
BSD 2-Clause "Simplified" License
8 stars 4 forks source link

Cannot find module after compiling #11

Open jeroen13 opened 4 years ago

jeroen13 commented 4 years ago

I've tried to use the main branch, as well as the windows branch (I assume that it is still being developed)

After installing 'node-mtp' I cannot use it in node.js.

C:\Users\Jeroen\Documents\Development\mtp>node index.js
internal/modules/cjs/loader.js:751
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Cannot find the module.
\\?\C:\Users\Jeroen\Documents\Development\mtp\node_modules\node-mtp\build\Release\module.node`
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:751:18)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at load (C:\Users\Jeroen\node_modules\node-gyp-build\index.js:21:10)
    at Object.<anonymous> (C:\Users\Jeroen\Documents\Development\mtp\node_modules\node-mtp\index.js:1:104)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)

Please note the path starts with: \\?C\the-rest-of-the-path

Has it something to do with the \\? The module.node exists in the path: C:\Users\Jeroen\Documents\Development\mtp\node_modules\node-mtp\build\Release\module.node

Also with normal npm install node-mtp it cannot find the module.node Using latest W10 X64

Thanks in advance!

gniezen commented 4 years ago

Hi Jeroen! Yes, I'm still working on adding Windows support. The "cannot find the module" error means that there's a .dll missing (specifically the libusb.dll), which I still need to add to the npm module.

Note that there's a caveat on Windows: node-mtp is a wrapper around libmtp, which uses libusb instead of the Windows MTP drivers to work. This means you'll have to install a libusb-win32 driver for the device you want to connect to, which can be done with https://zadig.akeo.ie/

Blogshot commented 4 years ago

Note that there's a caveat on Windows: node-mtp is a wrapper around libmtp, which uses libusb instead of the Windows MTP drivers to work. This means you'll have to install a libusb-win32 driver for the device you want to connect to, which can be done with https://zadig.akeo.ie/

Does this mean that a realease-version requires the user to install libusb or is this handled inside the module?

gniezen commented 4 years ago

It will require the user to install a USB driver ( which can be done using Zadig) that will replace the built-in Windows MTP driver. libusb itself will be handled inside the module. Once I get Windows support working properly, I'll try to write up everything in the README.

More details on Windows USB drivers and libusb are available here: https://github.com/libusb/libusb/wiki/Windows#how-to-use-libusb-on-windows

gniezen commented 4 years ago

@jeroen13 Can you try npm install node-mtp again, as I think all the relevant .dll's should now link correctly in v0.3.18?