SAP / node-rfc

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

SAPNWRFC.node could not be found #282

Closed DeanDavis closed 1 year ago

DeanDavis commented 1 year ago

Describe the bug I updated all my Node.js and NPM and packages to the latest versions. I expected some issues but I cannot resolve this one. Running my node.js script that used to work on previous versions of node-rfc I now get this error.

C:\Users\mercator\AppData\Roaming\npm\node_modules\node-rfc\lib\wrapper\noderfc-bindings.js:46 throw err; ^

Error: The specified procedure could not be found. \?\C:\Users\mercator\AppData\Roaming\npm\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.19042" }, "env": { "SAPNWRFC_HOME": "c:\nwrfcsdk", "RFC_INI": "", "nwrfcsdk_lib_on_path": true }, "versions": { "node": "18.15.0", "v8": "10.2.154.26-node.25", "uv": "1.44.2", "zlib": "1.2.13", "brotli": "1.0.9", "ares": "1.18.1", "modules": "108", "nghttp2": "1.51.0", "napi": "8", "llhttp": "6.0.10", "uvwasi": "0.0.15", "acorn": "8.8.2", "simdutf": "3.1.0", "undici": "5.20.0", "openssl": "3.0.8+quic", "cldr": "42.0", "icu": "72.1", "tz": "2022g", "unicode": "15.0", "ngtcp2": "0.8.1", "nghttp3": "0.7.0" } }

Environment

Additional context I Googled this and saw others with same/similar issue and have tried several of others fixes but nothing is working for me. Just looking for the next step to diagnosing this issue.

bsrdjan commented 1 year ago

Could it be you are using the older version of SAP NWRFC SDK library? To check, you can open the Windows shell (command prompt) and run

$ cd \nwrfcsdk\lib
$ findstr Patch sapnwrfc.dll
Fangfangp36 commented 9 months ago

@bsrdjan, could you please tell me which is the correct SAP NWRFC SDK lib version? I used the SDK version: C:\nwrfcsdk\lib>findstr Patch sapnwrfc.dll 750 Patch Level 12 Hotfix 2

and installed the node-rfc 3.3.1

but I got the same issue on my system: System: OS: Windows 10 10.0.19045 CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz Memory: 6.11 GB / 15.85 GB Binaries: Node: 20.11.0 - C:\Program Files\nodejs\node.EXE npm: 9.6.6 - C:\Program Files\nodejs\npm.CMD pnpm: 8.11.0 - ~\AppData\Roaming\npm\pnpm.CMD

################################################################ C:\Users\FangfangTan\projects\user-provision>node -p "require('node-rfc')" C:\Users\FangfangTan\node_modules\node-rfc\lib\noderfc-bindings.js:44 throw err; ^

Error: The specified module could not be found. \?\C:\Users\FangfangTan\node_modules\node-rfc\build\Release\sapnwrfc.node environment: { "platform": { "name": "win32", "arch": "x64", "release": "10.0.19045" }, "env": { "SAPNWRFC_HOME": "C:\nwrfcsdk", "RFC_INI": "", "nwrfcsdk_lib_on_path": true }, "versions": { "node": "20.11.0", "acorn": "8.11.2", "ada": "2.7.4", "ares": "1.20.1", "base64": "0.5.1", "brotli": "1.0.9", "cjs_module_lexer": "1.2.2", "cldr": "43.1", "icu": "73.2", "llhttp": "8.1.1", "modules": "115", "napi": "9", "nghttp2": "1.58.0", "nghttp3": "0.7.0", "ngtcp2": "0.8.1", "openssl": "3.0.12+quic", "simdutf": "4.0.4", "tz": "2023c", "undici": "5.27.2", "unicode": "15.0", "uv": "1.46.0", "uvwasi": "0.0.19", "v8": "11.3.244.8-node.17", "zlib": "1.2.13.1-motley-5daffc7" } }

at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at load (C:\Users\FangfangTan\node_modules\node-gyp-build\node-gyp-build.js:22:10)
at Object.<anonymous> (C:\Users\FangfangTan\node_modules\node-rfc\lib\noderfc-bindings.js:39:74)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (C:\Users\FangfangTan\node_modules\node-rfc\lib\index.js:24:14)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) {

code: 'ERR_DLOPEN_FAILED' }

bsrdjan commented 9 months ago

SAP NW RFC SDK shall never be installed, unless requested by SAP.

If requested by SAP, please send the ticket number or some reference. Otherwise, uninstall the hotfix and install the standard SAP NW RFC SDK 7.50 PL12

Fangfangp36 commented 9 months ago

@bsrdjan, thanks for the quick reply. I revert the SDK to: 750 PL 12 C:\nwrfcsdk\lib>findstr Patch sapnwrfc.dll 750 Patch Level 12

but I still got same issue, may you have other idea what is here wrong?

bsrdjan commented 9 months ago

Assuming the 64 bit RFC SDK is installed, not 32 bit, can you check if C:\nwrfcsdk\lib is on PATH ?

Also if the correct version of Microsoft Visual C++ redistributable is installed https://github.com/SAP/node-rfc?tab=readme-ov-file#windows

Fangfangp36 commented 9 months ago

@bsrdjan, I double checked C:\nwrfcsdk\lib is on PATH.

the sdk I used is nwrfc750P_12-70002755 it should be for win x64

and the installed Microsoft Visual C++ redistributable are:

Name Version


Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005 12.0.21005 Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005 12.0.21005 Microsoft Visual C++ 2022 X86 Debug Runtime - 14.38.33135 14.38.3... Microsoft Visual C++ 2022 X64 Debug Runtime - 14.38.33135 14.38.3... Microsoft Visual C++ 2022 X86 Additional Runtime - 14.38.3... 14.38.3... Microsoft Visual C++ 2022 X64 Additional Runtime - 14.38.3... 14.38.3... Microsoft Visual C++ 2022 X64 Minimum Runtime - 14.38.33130 14.38.3... Microsoft Visual C++ 2022 X86 Minimum Runtime - 14.38.33130 14.38.3...

bsrdjan commented 9 months ago

how the noder and noderfc are installed? if noderfc installed globally (npm -g) can you try the local installation? Perhaps your test user does not have permission to read globally installed node-rfc dll?

Fangfangp36 commented 9 months ago

Thank you Mr. Boskovic, but I actually installed noderfc locally.

bsrdjan commented 9 months ago

ERR_DLOPEN_FAILED is raised when DLL could not be loaded, because missing or when user does not have read permissions for DLL. To find out what exactly goes wrong

1) Send me the output of C:\nwrfcsdk\bin\startrfc -v, to verify the RFC SDK installation

2) Then either repeat the installation in another folder and try again, or

3) Run the Process Monitor to find out which DLL is not loaded. More info are in this comment and related issue https://github.com/SAP/node-rfc/issues/284#issuecomment-1490272036

In your case the test command for Process Monitor should load the node-rfc DLL (has extension .node). It is located in node_modules folder: node_modules/node-rfc/prebuilds/win32-x64/node.napi.node. The Process Monitor test command in your case should be something like below, lwith doubles slashes eventually

node -p "require('C:\Users\FangfangTan\projects\user-provision\node_modules\node-rfc\prebuilds\win32-x64\node.napi.node')"

Fangfangp36 commented 9 months ago

Thank you very much @bsrdjan, It seems the missing of MSVCR120.dll is the root cause:

  1. Run C:\nwrfcsdk\bin\startrfc -v got a system error MSVCR120.dll not found.
  2. Install the MS Virtual C++ 2012 Redistributable (x64)
  3. Run npm install node-rfc, it finished successfully
  4. check with node -p "require('node-rfc')" and got: { setIniFileDirectory: [Function: setIniFileDirectory], reloadIniFile: [Function: reloadIniFile], loadCryptoLibrary: [Function: loadCryptoLibrary], setLogFilePath: [Function: setLogFilePath], sapnwrfcEvents: EventEmitter { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, }, cancelClient: [Function: cancelClient], languageIsoToSap: [Function: languageIsoToSap], languageSapToIso: [Function: languageSapToIso], Promise: [Getter], noderfc_binding: [Getter], environment: [Getter], Client: [Getter], Pool: [Getter], Throughput: [Getter], Server: [Getter], RFC_RC: [Getter], EnumSncQop: [Getter], EnumTrace: [Getter], RfcParameterDirection: [Getter], RfcLoggingClass: [Getter], RfcLoggingLevel: [Getter], RFC_UNIT_STATE: [Getter] }
bsrdjan commented 9 months ago

just improved the troubleshooting steps documentation https://github.com/SAP/node-rfc/blob/main/doc/installation.md#verify-sap-nw-rfc-sdk-installation