invalid ELF header. The SAP NW RFC SDK could not be loaded on Linux #285
-
I am using node_rfc version 2.7.0 in my project. Deployment is in K8S and I have written following script saprfc-install.sh to create image
I call this script from my docker file.
This is working fine in my dev and staging k8s environment. However when I am testing on my windows laptop with docker desktop deployed , I get following error when executing connection with SAP _'Error: /opt/node_modules/node-rfc/lib/binding/sapnwrfc.node: invalid ELF header\n\n 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\nenvironment: {\n "platform": {\n "name": "linux",\n "arch": "x64",\n "release": "5.10.16.3-microsoft-standard-WSL2"\n },\n "env": {\n "SAPNWRFC_HOME": "/opt/nwrfcsdk",\n "RFC_INI": ""\n },\n "versions": {\n "node": "18.13.0",\n "v8": "10.2.154.23-n…272:10)\n at Module.load (node:internal/modules/cjs/loader:1081:32)\n at Module._load (node:internal/modules/cjs/loader:922:12)\n at Module.require (node:internal/modules/cjs/loader:1105:19)\n at require (node:internal/modules/cjs/helpers:103:18)\n at Object. (/opt/node_modules/@aas/xxx-sap_rfc-connector/common/lib/v1/RFCHelper.js:7:19)\n at Module._compile (node:internal/modules/cjs/loader:1218:14)\n at Module.extensions..js (node:internal/modules/cjs/loader:1272:10)' I am not able to figure out what's wrong with my local deployment. Any thoughts on further investigation will be helpful. P.S. cat /etc/os-release output from both dev/staging is ~$ cat /etc/os-release |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The problem could be
I suppose If you installed node-rfc on Windows and copy node_modules from there to docker, the "invalid ELF header" will come up because docker Linux tries to load node-rfc for Windows. Can you just replace the COPY node_modules ... with |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot Srdijan !! You are right. I was copying local node_modules to image and that's where issue was. Really silly mistake from me. Doing npm install during docker image build solves the issue. |
Beta Was this translation helpful? Give feedback.
The problem could be
I suppose
node_modules
on your Windows laptop include node-rfc installed there. The node-rfc is platform dependent and has a binary component for Windows and another one for Linux.If you installed node-rfc on Windows and copy node_modules from there to docker, the "invalid ELF header" will come up because docker Linux tries to load node-rfc for Windows.
Can you just replace the COPY node_modules ... with
npm install node-rfc
? That would install the proper Linux version of node-rfc.