SAP / node-rfc

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

Electron platform support: The SAP NW RFC SDK could not be loaded #257

Closed siasty closed 1 year ago

siasty commented 2 years ago

Hi, i have a specific problem with running the library. When I run a simple script with node-rfc everything works fine, but when I want to use the library in vs code extesion i have error "The SAP NW RFC SDK could not be loaded, check the installation " in first line "const noderfc = require("node-rfc");"

I also have settings in vs code to always includes libraries

do you have any idea what is wrong?

To Reproduce https://github.com/siasty/abaprfc.git command code hello world

Screenshots Przechwytywanie

Environment

{
  platform: { name: 'win32', arch: 'x64', release: '10.0.19044' },
  env: {
    SAPNWRFC_HOME: 'C:\\nwrfcsdk',
    RFC_INI: '',
    nwrfcsdk_lib_on_path: true
  },
  versions: {
    node: '16.14.2',
    v8: '9.4.146.24-node.20',
    uv: '1.43.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    ares: '1.18.1',
    modules: '93',
    nghttp2: '1.45.1',
    napi: '8',
    llhttp: '6.0.4',
    openssl: '1.1.1n+quic',
    cldr: '40.0',
    icu: '70.1',
    tz: '2021a3',
    unicode: '14.0',
    ngtcp2: '0.1.0-DEV',
    nghttp3: '0.1.0-DEV'
  },
  noderfc: {
    version: '2.6.1',
    nwrfcsdk: { major: 7500, minor: 0, patchLevel: 9 }
  }
}
siasty commented 2 years ago
Error: Procedura inicjowania biblioteki do³¹czanej dynamicznie (DLL) nie powiod³a siê.
\\?\d:\abaprfc\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.19043"
  },
  "env": {
    "SAPNWRFC_HOME": "C:\\nwrfcsdk",
    "RFC_INI": "",
    "nwrfcsdk_lib_on_path": false
  },
  "versions": {
    "node": "16.13.0",
    "v8": "9.8.177.11-electron.0",
    "uv": "1.42.0",
    "zlib": "1.2.11",
    "brotli": "1.0.9",
    "ares": "1.17.2",
    "modules": "101",
    "nghttp2": "1.45.1",
    "napi": "8",
    "llhttp": "6.0.4",
    "openssl": "1.1.1",
    "cldr": "40.0",
    "icu": "70.1",
    "tz": "2021a3",
    "unicode": "14.0",
    "electron": "17.2.0",
    "microsoft-build": "12680806"
  }
}

    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1800)
    at Object.<anonymous> (node:internal/modules/cjs/loader:1246:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1800)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at node:internal/modules/cjs/loader:876:12
    at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
    at Function.<anonymous> (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:32156)
    at Function.<anonymous> (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:28749)
    at Function._load (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:61429)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (d:\abaprfc\node_modules\node-rfc\lib\wrapper\noderfc-bindings.js:36:49)
    at Module._compile (node:internal/modules/cjs/loader:1163:14)
    at Object..js (node:internal/modules/cjs/loader:1216:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at node:internal/modules/cjs/loader:876:12
    at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
    at Function.<anonymous> (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:32156)
    at Function.<anonymous> (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:28749)
    at Function._load (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:61429)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (d:\abaprfc\node_modules\node-rfc\lib\index.js:20:14)
    at Module._compile (node:internal/modules/cjs/loader:1163:14)
    at Object..js (node:internal/modules/cjs/loader:1216:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at node:internal/modules/cjs/loader:876:12
    at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
    at Function.<anonymous> (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:32156)
    at Function.<anonymous> (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:28749)
    at Function._load (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:61429)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at d:\abaprfc\out\extension.js:9:29
    at m._executeContributedCommand (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:30760)
    at m.$executeContributedCommand (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:31302)
    at i._doInvokeHandler (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:13826)
    at i._invokeHandler (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:13510)
    at i._receiveRequest (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:12171)
    at i._receiveOneMessage (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:10841)
    at d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:89:8947
    at u.invoke (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at d.fire (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19034)
    at d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:34275
    at u.invoke (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at d.fire (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19034)
    at o._receiveMessage (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:23615)
    at d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:21149
    at u.invoke (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145)
    at v.fire (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1856)
    at v.acceptChunk (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:15865)
    at d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:14995
    at Socket.P (d:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:13797)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) {code: 'ERR_DLOPEN_FAILED', stack: 'Error: Procedura inicjowania biblioteki do³¹c…Trampoline (node:internal/async_hooks:130:17)', message: 'Procedura inicjowania biblioteki do³¹czanej …0",
    "microsoft-build": "12680806"
  }
}
'}
bsrdjan commented 2 years ago

Just found related SO question https://stackoverflow.com/questions/72011527/how-to-use-node-rfc-in-vscode-extension-development

Did you try to install the node-rfc globally, in nodejs version used by vs code?

siasty commented 2 years ago

yes I tried, i install nodejs version as usesd by vsc i also build node-rfc in my local machine but I have the same result

bsrdjan commented 2 years ago

in a first log (working example), the environment shows"nwrfcsdk_lib_on_path": true

in 2nd log (error), it shows "nwrfcsdk_lib_on_path": false which means SAP NWRFC SDK dll files are probably not on path.

The RFC SDK dll files path is determined by SAPNWRFC_HOME env variable and lib subfolder added, should be c:\nwrfcsdk\lib on your system.

Can you check if c:\nwrfcsdk\lib is on PATH when running from VSCode? Print the PATH to console before (or without) loading node-rfc for example.

siasty commented 2 years ago

Hi, environmental values are set correctly and read by vscode.... I've tried many things ;/ maybe that's why I had "nwrfcsdk_lib_on_path": false .... from log... Commands registered SAPNWRFC_HOME: C:\nwrfcsdk Path: C:\Python310\Scripts\;C:\Python310\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\ProgramData\chocolatey\bin;C:\nwrfcsdk\lib;D:\Program Files\CMake\bin;D:\Program Files\nodejs\;C:\Users\siast\AppData\Local\Microsoft\WindowsApps;D:\Programs\Microsoft VS Code\bin;C:\Users\siast.dotnet\tools;C:\nwrfcsdk\lib;D:\Program Files\CMake\bin;C:\Users\siast\AppData\Roaming\npm

Error: Procedura inicjowania biblioteki do³¹czanej dynamicznie (DLL) nie powiod³a siê. \?\d:\repos_vc_abap\test-rfc-vsc\testrfc\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.19044" }, "env": { "SAPNWRFC_HOME": "C:\nwrfcsdk", "RFC_INI": "", "nwrfcsdk_lib_on_path": true }, "versions": { "node": "16.13.0", "v8": "9.8.177.11-electron.0", "uv": "1.42.0", "zlib": "1.2.11", "brotli": "1.0.9", "ares": "1.17.2", "modules": "101", "nghttp2": "1.45.1", "napi": "8", "llhttp": "6.0.4", "openssl": "1.1.1", "cldr": "40.0", "icu": "70.1", "tz": "2021a3", "unicode": "14.0", "electron": "17.2.0", "microsoft-build": "12680806" } }

at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1800)
at Object.<anonymous> (node:internal/modules/cjs/loader:1246:18)
at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1800)
at Module.load (node:internal/modules/cjs/loader:1035:32)
at node:internal/modules/cjs/loader:876:12
at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
at Function.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:32156)
at Function.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:28749)
at Function._load (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:61429)
at Module.<anonymous> (node:internal/modules/cjs/loader:1059:19)
at Module.require (c:\Users\siast\.vscode\extensions\sapos.yeoman-ui-1.7.7\dist\extension.js:2:2023551)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (d:\repos_vc_abap\test-rfc-vsc\testrfc\node_modules\node-rfc\lib\wrapper\noderfc-bindings.js:36:49)
at Module._compile (node:internal/modules/cjs/loader:1163:14)
at Object..js (node:internal/modules/cjs/loader:1216:10)
at Module.load (node:internal/modules/cjs/loader:1035:32)
at node:internal/modules/cjs/loader:876:12
at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
at Function.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:32156)
at Function.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:28749)
at Function._load (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:61429)
at Module.<anonymous> (node:internal/modules/cjs/loader:1059:19)
at Module.require (c:\Users\siast\.vscode\extensions\sapos.yeoman-ui-1.7.7\dist\extension.js:2:2023551)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (d:\repos_vc_abap\test-rfc-vsc\testrfc\node_modules\node-rfc\lib\index.js:20:14)
at Module._compile (node:internal/modules/cjs/loader:1163:14)
at Object..js (node:internal/modules/cjs/loader:1216:10)
at Module.load (node:internal/modules/cjs/loader:1035:32)
at node:internal/modules/cjs/loader:876:12
at Function.<anonymous> (node:electron/js2c/asar_bundle:5:13331)
at Function.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:32156)
at Function.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:28749)
at Function._load (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:99:61429)
at Module.<anonymous> (node:internal/modules/cjs/loader:1059:19)
at Module.require (c:\Users\siast\.vscode\extensions\sapos.yeoman-ui-1.7.7\dist\extension.js:2:2023551)
at require (node:internal/modules/cjs/helpers:102:18)
at activate (d:\repos_vc_abap\test-rfc-vsc\testrfc\out\extension.js:13:25)
at Function._callActivateOptional (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:16070)
at Function._callActivate (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:15731)
at d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:90:13549
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async g._activate (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:8154)
at async g._waitForDepsThenActivate (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:8096)
at async g._initialize (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:7460) {code: 'ERR_DLOPEN_FAILED', stack: 'Error: Procedura inicjowania biblioteki do³¹c…nch\api\node\extensionHostProcess.js:85:7460)', message: 'Procedura inicjowania biblioteki do³¹czanej …0",
"microsoft-build": "12680806"

} } '}

siasty commented 2 years ago

and code of simple extension `import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {

console.log('SAPNWRFC_HOME: ' + process.env.SAPNWRFC_HOME);
console.log('Path: ' + process.env.PATH);

try {
    const noderfc = require("node-rfc");
} catch (ex) {
    console.log(ex);
}

let disposable = vscode.commands.registerCommand('testrfc.helloWorld', () => {

    vscode.window.showInformationMessage('Hello World from testrfc!');
});

context.subscriptions.push(disposable);

}

export function deactivate() { } `

jamess0160 commented 2 years ago

Hi, I think I have the same problem, but outside of vscode. I configured everything correctly and it still gives me the same error. I did a test calling the SDK through python and the connection worked correctly image

siasty commented 2 years ago

Hi i also use pyrfc to test and works correctly

Zefau commented 2 years ago

Any solution / ideas on this? I'm experiencing the same issue.

bsrdjan commented 2 years ago

@siasty could you please describe step by step how to reproduce? From cloning the extension repo to getting the error line in screenshot?

bsrdjan commented 2 years ago

I could not reproduce on MacOS, see screenshot below. Is it how it is supposed to work?

Screenshot 2022-06-10 at 13 55 30
siasty commented 2 years ago

hello I have to write a new repository this source has evolved to something else I didn't have the strength for node-rfc anymore. i start using pyrfc

siasty commented 2 years ago

in the evening I will add a new source

siasty commented 2 years ago

https://github.com/siasty/testnoderfc.git

bsrdjan commented 2 years ago

Finally reproduced on Windows only, it works on MacOS and Linux.

SAP NWRFC SDK is not supported on electron platform, on which VS Code is running and that is why it is not loading on Windows. The feature can be requested from SAP product development, as described here: https://github.com/SAP/node-rfc/issues/144

The test is done by standard generated "Hello World" extension, with following trace added to extenstion.ts:

      // Display a message box to the user
      const RFC = require("node-rfc");
      const client = new RFC.Client({
        ashost: "host",
        user: "user",
        passwd: "passwd",
        sysnr: "00",
        lang: "en",
      });
      vscode.window.showInformationMessage(JSON.stringify(client.environment));
bsrdjan commented 1 year ago

Electron is supported as of node-rfc@3.1, also on Windows