SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
251 stars 73 forks source link

The specified module could not be found #210

Closed vyking60 closed 3 years ago

vyking60 commented 3 years ago

I have installed SAP RFC SDK 750 on win X64. All post installation checks are OK, till loading node-rfc modules. Copying nwrfcsdk\lib files (dll,...) to widows\system32 also didn't help

Environment looks OK: C:\Users\si4uoh>@echo off findstr Patch "%SAPNWRFC_HOME%\lib\sapnwrfc.dll" 750 Patch Level 7

Also PATH is OK

STARTRFC returns OK response form target SAP system (SAP system ID , netweaver version,...)

BUT node -p "require('node-rfc')" returns:

PS C:\_Data\_DEVELOPMENT\Node\saprfc> node -p "require('node-rfc')"
C:\_Data\_DEVELOPMENT\Node\saprfc\node_modules\node-rfc\lib\wrapper\noderfc-bindings.js:45
    throw ex;
    ^

Error: The specified module could not be found.
\\?\C:\_Data\_DEVELOPMENT\Node\saprfc\node_modules\node-rfc\lib\binding\sapnwrfc.node

 The SAP NW RFC SDK could not be loaded, check the installation: https://github.com/SAP/node-rfc/blob/master/doc/installation.md#sap-nwrfc-sdk-installation
environment: {
  "platform": {
    "name": "win32",
    "arch": "x64",
    "release": "10.0.15063"
  },
  "env": {
    "SAPNWRFC_HOME": "C:\\Program Files\\SAP RFC SDK 750\\nwrfcsdk",
    "RFC_INI": "",
    "nwrfcsdk_lib_on_path": true
  },
  "versions": {
    "node": "14.16.1",
    "v8": "8.4.371.19-node.18",

How I can find where the problem is?

bsrdjan commented 3 years ago

Is it maybe running on Microsoft IIS: https://github.com/SAP/node-rfc/issues/139 ?

Did you check if Visual C++ 2013 re-distributable installed: https://github.com/SAP/node-rfc#windows ?

How is node-rfc installed? Locally/globally, using npm install or built from source?

bsrdjan commented 3 years ago

If nothing of above helps, the procmon can help find the missing part: https://github.com/SAP/node-rfc/issues/127#issuecomment-600020359

vyking60 commented 3 years ago

Thanks for quick response! IIS is not used. I am working directly in VSCode C++ 2013 is installed - even both x386 and X64 node-rfc is installed with npm locally. During debugging I see that exception is catched in noderfc-bindings.js on line 36:

exports.noderfc_binding = noderfc_binding = require("../binding/sapnwrfc");

And I see file sapnwrfc.node in bindings folder.

How can I get help procman?

bsrdjan commented 3 years ago

procman can trace the DLLs loading chain, to find out which DLL exactly fails. Example: https://github.com/SAP/node-rfc/issues/127#issuecomment-600020359

The VSCode itself does not matter but the re-distributable is important (Add/Remove Programs screenshot):

Screenshot 2021-04-15 at 14 32 49

If x86 not needed, best remove it and/or try to re-install the re-distributable.

You can trace runtime info before exception, adding something like this in node_modules/node-rfc/lib/wrapper/noderfc-bindings.js

// verify SAP NWRFC SDK is on PATH
console.log(process.env.PATH)
try {
    exports.noderfc_binding = noderfc_binding = require("../binding/sapnwrfc");
}

Could you please post the output of:

dir %SAPNWRFC_HOME%\lib
vyking60 commented 3 years ago

Visual C+ x386 is uninstalled;
Visual C++ 2013 X64 is still installed

Console.log of PATH and SAPNWRFC_HOME before exports.noderfc...: image

dir %SAPNWRFC_HOME%\lib from TERMINAL node app folder: Variable not evaluated!! image

dir ​from Command prompt; image

bsrdjan commented 3 years ago

dir %SAPNWRFC_HOME%\lib from TERMINAL node app folder: Variable not evaluated!!

The PowerShell syntax is dir $env:SAPNWRFC_HOME\lib, should be fine

The NWRFC SDK looks like correct 64 bit version, no idea what else to check. RFC SDK files look correct and should work with the "lib" folder on PATH.

Perhaps to try with another Windows user or fresh new Windows installation. C++ redistributable re-installations do not always work as expected. Some users reported in Issues that only re-installation helped.

Or trace with procmon first.

vyking60 commented 3 years ago

Reinstallation would be the last option. I played with procmon and created one file. Can you check it if there is anything to see. Otherwise I would need some help to produce usefull one Logfile.zip

vyking60 commented 3 years ago

Problem solved. Thanks for help, Srdjan. (Re)Installation of C++ Build tools helped (MSVC 14.28)