ezra-bible-app / node-sword-interface

JavaScript (N-API) interface to SWORD library
GNU General Public License v2.0
22 stars 2 forks source link

node showing error "The specified module could not be found" when loading node-sword-interface on Windows #35

Closed rockymartin0124 closed 1 year ago

rockymartin0124 commented 1 year ago

I have installed node-sword-interface in my PC using "npm install node-sword-interface --arch=ia32". And I tried "node examples/install_kjv.js". But I got an error like this.

D:\Workshop\node-sword-interface>node examples/install_kjv.js internal/modules/cjs/loader.js:800 return process.dlopen(module, path.toNamespacedPath(filename)); ^

Error: The specified module could not be found. \?\D:\Workshop\node-sword-interface\build\Release\node_sword_interface.node at Object.Module._extensions..node (internal/modules/cjs/loader.js:800:18) at Module.load (internal/modules/cjs/loader.js:628:32) at Function.Module._load (internal/modules/cjs/loader.js:555:12) at Module.require (internal/modules/cjs/loader.js:666:19) at require (internal/modules/cjs/helpers.js:16:16) at Object. (D:\Workshop\node-sword-interface\index.js:20:34) at Module._compile (internal/modules/cjs/loader.js:759:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10) at Module.load (internal/modules/cjs/loader.js:628:32) at Function.Module._load (internal/modules/cjs/loader.js:555:12)

I have tried with node v14.21.2 32bit and node v12.0.0 32 bit. What is the solution for this problem?

tobias-klein commented 1 year ago

Thank you for reporting this! It seems like this is a Windows specific issue. I could reproduce it and I will look for a solution!

tobias-klein commented 1 year ago

@rockymartin0124 I figured out the root cause!

The reason is that the DLL files that the native module depends on cannot be found and subsequently node gives you that error message when requiring the module. The DLL files are actually available under build/sword-build-win32/lib and in the context of the Ezra Bible App build for Windows these files are then automatically copied to the folder build/Release where the node_sword_interface.node module file is located.

I need to check how can fix this more permanently for the Windows build, but in the meanwhile you can apply the following work around. Copy the dll files manually to the build directory of node_sword_interface by executing the following command on a command shell within node_modules/node_sword_interface.

copy build/sword-build-win32/lib/* build/Release/

shev72 commented 1 year ago

Hello, yes I had the same issue. Thanks Tobias, I confirm that the workaround works.

tobias-klein commented 1 year ago

@shev72 Thanks for confirming! I'll definitely check how to fix this. Probably this should be some kind of post installation script just executed on Windows.

rockymartin0124 commented 1 year ago

@tobias-klein

Thanks for your reply. I solved the error "The specified module could not be found".

I executed the command "node examples/install_kjv.js" again, and got the scripts like this.

Updating repository configuration ...

refreshRemoteSourceConfiguration returned -1 Installing King James module getModuleRepo: Got 0 repository names! Could not find repository for module KJV (node:8308) UnhandledPromiseRejectionWarning: -1 (Use node --trace-warnings ... to show where the warning was created) (node:8308) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:8308) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Please explain about this.

tobias-klein commented 1 year ago

@rockymartin0124 This usually happens when you have internet connectivity issues. Can you try to run the command again? If it keeps happening you could manually configure a higher timeout parameter for the SWORD library. This has been described here: https://github.com/ezra-bible-app/ezra-bible-app/issues/155#issuecomment-750302401

rockymartin0124 commented 1 year ago

@tobias-klein I tried to run the command again, but it's the same. I have checked the comment https://github.com/ezra-bible-app/ezra-bible-app/issues/155#issuecomment-750302401

I have no such file: C:\Users\<your-user-name>\AppData\Roaming\sword\installMgr\InstallMgr.conf. There is InstallMgr, but the folder is empty. What can I do?

tobias-klein commented 1 year ago

@rockymartin0124 Try to delete the complete sword directory C:\Users\<your-user-name>\AppData\Roaming\sword. Then repeat executing the command from above.

rockymartin0124 commented 1 year ago

I tried to delete the complete sword directory and repeated the command. But I got the same result. I must run node-sword-interface, and I am sure that you will give me the solution.

tobias-klein commented 1 year ago

@rockymartin0124 Let's continue the discussion in #37, because this is independent of the original issue.

tobias-klein commented 1 year ago

The solution for this is now available as part of node-sword-interface 1.0.5 (published on npmjs).