Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-rfc not running when using Node.js in "standalone mode" #238

Closed
Zefau opened this issue Oct 21, 2021 · 6 comments
Closed

node-rfc not running when using Node.js in "standalone mode" #238

Zefau opened this issue Oct 21, 2021 · 6 comments

Comments

@Zefau
Copy link

Zefau commented Oct 21, 2021

Describe the bug

Connecting via node-rfc with an installed version of Node.js works perfectly fine (via command-line node script.js).

Using the standalone exe file from Node.js (meanig node.exe from the binaries available at https://nodejs.org/en/download/) the error Error: A dynamic link library (DLL) initialization routine failed. is thrown.

To Reproduce

Running the following script (saved in script.js) via node script.js on the command line works perfectly.
The result outputs the result of the remote function.

console.log(`Node.js Version: ${process.version}`);

process.env.PATH = process.env.PATH + ';' + process.cwd() + '\\lib\\binding;' + process.cwd() + '\\lib\\nwrfcsdk\\lib;' + process.cwd() + '\\lib\\nwrfcsdk;';
process.env.SAPNWRFC_HOME = process.cwd() + '\\lib\\nwrfcsdk';

/*
 */
const noderfc = require('node-rfc');
console.log(noderfc.noderfc_binding);
console.log(noderfc.environment);

const logon = {
	... valid logon details ...
}

const pool = new noderfc.Pool({ 'connectionParameters': logon });

(async () => {
	try {
		const client = await pool.acquire();
		const result = await client.call("RFC_SYSTEM_INFO", {});
		console.log(result);
	}
	catch (error) {
		console.error(error);
	}
})();

Running the same script via downloaded exe-file using node.exe script.js (when being the same folder) results in the error mentioned above.

The path(s) to the nwrfcsdk is valid in both cases (via PATH variable, which is set in the beginning of the script). Furthermore, the sapnwrfc.node is also found on the paths provided (in case it is not found a different error is thrown).

The same setup works e.g. for better-sqlite3 (https://www.npmjs.com/package/better-sqlite3), which also compiled to a .node file. Though, an additional path to a sdk is not required.

Screenshots

None.

Environment

Installed Node.js outputs:

Node.js Version: v14.18.0
{
  platform: { name: 'win32', arch: 'x64', release: '10.0.18363' },
  env: {
    SAPNWRFC_HOME: 'C:\\Users\\... valid path ...\\lib\\nwrfcsdk',
    RFC_INI: '',
    nwrfcsdk_lib_on_path: true
  },
  versions: {
    node: '14.18.0',
    v8: '8.4.371.23-node.84',
    uv: '1.42.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    ares: '1.17.2',
    modules: '83',
    nghttp2: '1.42.0',
    napi: '8',
    llhttp: '2.1.3',
    openssl: '1.1.1l',
    cldr: '39.0',
    icu: '69.1',
    tz: '2021a',
    unicode: '13.0'
  },
  noderfc: {
    version: '2.5.1',
    nwrfcsdk: { major: 7500, minor: 0, patchLevel: 8 }
  }
}

Standalone Node.js outputs:

Node.js Version: v14.18.0
C:\Users\ ... \node_modules\node-rfc\lib\wrapper\noderfc-bindings.js:45
    throw ex;
    ^

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\ ... \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.18363"
  },
  "env": {
    "SAPNWRFC_HOME": "C:\\Users\\... same path as above ...\\lib\\nwrfcsdk",
    "RFC_INI": "",
    "nwrfcsdk_lib_on_path": true
  },
  "versions": {
    "node": "14.18.0",
    "v8": "8.4.371.23-node.84",
    "uv": "1.42.0",
    "zlib": "1.2.11",
    "brotli": "1.0.9",
    "ares": "1.17.2",
    "modules": "83",
    "nghttp2": "1.42.0",
    "napi": "8",
    "llhttp": "2.1.3",
    "openssl": "1.1.1l",
    "cldr": "39.0",
    "icu": "69.1",
    "tz": "2021a",
    "unicode": "13.0"
  }
}

Additional context

I think solving this might also be solving #144.

@bsrdjan
Copy link
Member

bsrdjan commented Oct 21, 2021

Could you please describe steps how to install/run NodeJS in "standalone mode" on Windows?

@Zefau
Copy link
Author

Zefau commented Oct 21, 2021

  1. Downloading node.exe from https://nodejs.org/dist/v14.18.1/win-x64/ (in my case x64)
  2. Copying node.exe and the script above in the same folder (alternatively renaming node.exe to cli.exe or anything)
  3. Opening command prompt in that folder
  4. Running node.exe script.js (or cli.exe script.js) [ Note that .exe is important; otherwise the global installed Node.js will be used ]

@bsrdjan
Copy link
Member

bsrdjan commented Oct 21, 2021

The nodejs installation from binary archive is described only for Linux and it should work the similar way on Windows:

https://github.com/nodejs/help/wiki/Installation

The complete Windows binary archive should be downloaded and that bin folder must be first (or prioritized) on PATH, like described in above mentioned documentation.

Could you please try if it works with the recommended installation?

@Zefau
Copy link
Author

Zefau commented Oct 21, 2021

Unbelievable - thank you very much for your help.

There is no bin folder in the windows binaries and it works only with the node.exe. But apparently it is slightly different in the binaries than the one I downloaded before?! The one in the binary works now as expected. And renaming the exe-file like I wrote above does not work - needs to be named node.exe.

@Zefau Zefau closed this as completed Oct 21, 2021
@bsrdjan
Copy link
Member

bsrdjan commented Oct 21, 2021

That is interesting, perhaps this is indeed the issue happening in #144?

@Zefau
Copy link
Author

Zefau commented Oct 22, 2021

Seems like it, but I don't know how to solve this with respect to Electron. I was also trying to get node-rfc running with Electron, but I failed, which is why I ended up using this "standone mode" of Node.js as a fallback.

I was also trying pkg (https://www.npmjs.com/package/pkg), which apparentely uses an own compiled version of Node.js in some way. With pkg it also fails - same as Electron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants