ngrok / ngrok-javascript

Embed ngrok secure ingress into your Node.js apps with a single line of code.
https://ngrok.com
Apache License 2.0
98 stars 18 forks source link

`The specified module could not be found` error on Windows #142

Closed chetbox closed 3 months ago

chetbox commented 4 months ago

Many of our Windows users are getting the following error when initialising our Electron app which includes this library:

The specified module could not be found.
\\?\C:\Users\[redacted]\AppData\Local\[app_name]\app-5.3.1\resources\app.asar.unpacked\.webpack\renderer\node_modules\@ngrok\ngrok-win32-x64-msvc\ngrok.win32-x64-msvc.node

Note that we are using Electron Forge and have set in forge.config.js:

module.exports = {
  packagerConfig: {
    asar: {
      unpack: '*.node'
    }
}

Which works perfectly fine for other native libraries like serialport.

I have tried installing the same application on our own Windows 10 and Windows 11 machines and I can confirm: 1) The file exists 2) The module is loaded 3) I can connect to Ngrok

What could be causing this?

Does the MSVC runtime need to be installed on the target computer? I can't see any like that in the documentation but I'm at a loss as to what else could be causing this problem.

Edit: I am using version 1.2.0

chetbox commented 3 months ago

I have tracked the issue down on a clean Windows install. The problem was indeed that the Microsoft Visual C++ Redistributable is not installed.

Our workaround for now is bundling vcruntime140.dll into the application in the same folder as ngrok.win32-x64-msvc.node.

I think this should be, at the very least, mentioned in the installation instructions. Ideally this library would bundle the DLL file for machines where MSVC is not installed.

salilsub commented 3 months ago

I've opened an issue to update our README with this information. I don't think we would want to bundle this in the SDK since it would not be relevant for non-Windows users.

chetbox commented 3 months ago

There is a subpackage specifically for each architecture/platform pair and I think it would make a lot of sense to bundle the DLL in the Windows MSVC one.