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

npm install node-rfc doesn't work #35

Closed
ManuelMittler opened this issue Sep 25, 2017 · 27 comments
Closed

npm install node-rfc doesn't work #35

ManuelMittler opened this issue Sep 25, 2017 · 27 comments

Comments

@ManuelMittler
Copy link

ManuelMittler commented Sep 25, 2017

Hi there,

i was trying to install node-rfc but I get this errors:
ode-pre-gyp ERR! Tried to download(404): https://github.com/sap/node-rfc/releases/download/0.1.11/rfc-v0.1.11-node-v57-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI) (falling back to source compile with node-gyp)
make: Entering directory /var/www/PRG/playground/authentication/node-rfc/build' CXX(target) Release/obj.target/rfc/src/rfc.o In file included from ../src/rfc.cc:16:0: ../src/Client.h:23:22: fatal error: sapnwrfc.h: No such file or directory #include <sapnwrfc.h> ^ compilation terminated. make: *** [Release/obj.target/rfc/src/rfc.o] Error 1 make: Leaving directory /var/www/PRG/playground/authentication/node-rfc/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/opt/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.13.0-042stab124.2
gyp ERR! command "/opt/node/bin/node" "/opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/var/www/PRG/playground/authentication/node-rfc/build/rfc/rfc.node" "--module_name=rfc" "--module_path=/var/www/PRG/playground/authentication/node-rfc/build/rfc"
gyp ERR! cwd /var/www/PRG/playground/authentication/node-rfc
gyp ERR! node -v v8.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/opt/node/bin/node /opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/var/www/PRG/playground/authentication/node-rfc/build/rfc/rfc.node --module_name=rfc --module_path=/var/www/PRG/playground/authentication/node-rfc/build/rfc' (1)
node-pre-gyp ERR! stack at ChildProcess. (/var/www/PRG/playground/authentication/node-rfc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:927:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 3.13.0-042stab124.2
node-pre-gyp ERR! command "/opt/node/bin/node" "/var/www/PRG/playground/authentication/node_modules/node-rfc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /var/www/PRG/playground/authentication/node-rfc
node-pre-gyp ERR! node -v v8.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok
Failed to execute '/opt/node/bin/node /opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/var/www/PRG/playground/authentication/node-rfc/build/rfc/rfc.node --module_name=rfc --module_path=/var/www/PRG/playground/authentication/node-rfc/build/rfc' (1)
npm WARN enoent ENOENT: no such file or directory, open '/var/www/PRG/playground/authentication/package.json'
npm WARN authentication No description
npm WARN authentication No repository field.
npm WARN authentication No README data
npm WARN authentication No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-09-25T13_53_07_192Z-debug.log

Has someone an idea?

Thanks a lot in advance!

@TheGreenToaster
Copy link
Contributor

I had this issue. My problem was my path was not set correctly with the NWRFCSDK lib path. Described here

@bsrdjan
Copy link
Contributor

bsrdjan commented Oct 18, 2017

Pre-compiled binary might not be available for your nodejs version. Which nodejs version are you using ?

The build from source should anyway work, with SAPNWRFC_HOME set to base folder of sapnwrfcsdk installed on your system (see my answer in #36).

@PrakashSadasivam
Copy link

I am facing the same issue installing on Linux with node.js 8.9.1 version.

Any idea? What am I missing?

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 26, 2017

Pre-compiled binary is not available for 8.9.1, only the build from source.

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 28, 2017

Just released 0.1.12 has 8.9 included and you may test in your system.

@PrakashSadasivam
Copy link

Thanks @bsrdjan.

@StefanScherer
Copy link

Awesome @bsrdjan, I tried to install on Windows, but still get 0.1.11 from npmjs.org

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 29, 2017

Thank you very much @StefanScherer for catching this one. The version publish failed on npmjs, now should be fixed.

@StefanScherer
Copy link

@bsrdjan Thanks for the update. I've tried it with Node.js 8.9.1 on Windows, but during the installation I see this error:

npm info lifecycle [email protected]~install: [email protected]

> [email protected] install C:\test\node_modules\node-rfc
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | x64
node-pre-gyp info check checked for "C:\test\node_modules\node-rfc\build\rfc\rfc.node" (not found)
node-pre-gyp http GET https://github.com/sap/node-rfc/releases/download/0.1.12/rfc-v0.1.12-node-v57-win32-x64.tar.gz
node-pre-gyp http 404 https://github.com/sap/node-rfc/releases/download/0.1.12/rfc-v0.1.12-node-v57-win32-x64.tar.gz
node-pre-gyp ERR! Tried to download(404): https://github.com/sap/node-rfc/releases/download/0.1.12/rfc-v0.1.12-node-v57-win32-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://github.com/sap/node-rfc/releases/download/0.1.12/rfc-v0.1.12-node-v57-win32-x64.tar.gz 

C:\test\node_modules\node-rfc>if not defined npm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node "" clean ) 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info ok 

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 29, 2017

Thank you Stefan, binary names should be fixed now. Please feel free to check.

@StefanScherer
Copy link

I tried 0.1.12 in a Linux container, based on FROM node:6.12.0, but I get a shared library error

module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /code/node_modules/node-rfc/build/rfc/rfc.node)
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/code/node_modules/node-rfc/index.js:6:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

It works fine if I switch back to 0.1.11.

Dependencies of the 0.1.11 version:

root@108e5b0eefdc:/code/node_modules/node-rfc/build/rfc# ldd rfc.node 
	linux-vdso.so.1 (0x00007ffe1fba2000)
	libsapnwrfc.so => /nwrfcsdk/lib/libsapnwrfc.so (0x00007f8032aa0000)
	libsapucum.so => /nwrfcsdk/lib/libsapucum.so (0x00007f803352b000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8032795000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8032578000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f80321cd000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8031fc9000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8031dc1000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f8031bbc000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f80318bb000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f80316a5000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f80334be000)

Dependencies of the 0.1.12 version:

root@da22b15c0530:/code/node_modules/node-rfc/build/rfc# ldd rfc.node 
./rfc.node: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./rfc.node)
	linux-vdso.so.1 (0x00007ffd47dc7000)
	libsapnwrfc.so => /nwrfcsdk/lib/libsapnwrfc.so (0x00007f2efc3d1000)
	libsapucum.so => /nwrfcsdk/lib/libsapucum.so (0x00007f2efce5e000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2efc0c6000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2efbd1b000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2efbb17000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2efb90f000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f2efb70a000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2efb409000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2efb1f3000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2efafd6000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2efcdf1000)

@StefanScherer
Copy link

I ran another test in a Windows Server Core container and DLL's can be loaded with both 0.1.11 and 0.1.12 using Node.js 6.12.0.

BTW: I first tried the smaller NanoServer container, but it seems the the nwsdk DLL and binaries (from NWRFC_38-20004568.SAR) don't work in NanoServer.

Will do a more deep test if I have a SAP system at hand to connect to.

@StefanScherer
Copy link

Same error appears with FROM node:8.9.1 on Linux with node-rfc 0.1.12:
Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ...

Windows with FROM stefanscherer/node-windows:8.9.1-windowsservercore is fine with both 0.1.12.

Both Linux and Windows fail of course when trying with 0.1.11.

@PrakashSadasivam
Copy link

PrakashSadasivam commented Nov 29, 2017

@bsrdjan,. I am not sure this is place to ask but any help is much appreciated.
We are trying to use node-rfc package in AWS lambda but curious to know that it's supported, we are a bit skeptical about it because it has a dependency on SAP NW libraries. Any idea? We are not sure how we can set a dynamic link to SAP libraries.

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 30, 2017

@PrakashSadasivam, regarding AWS Lambda, I am not much familiar with that platform and similar question is posted for Python RFC Connector SAP-archive/PyRFC#51. Both Python and nodejs RFC connector require native SAP NW RFC SDK libraries to be deployed. If that not possible, these connectors can't be used on that platform.

If your target SAP system has HANA database and access to database is enough for your case, you may try HANA db connectors for Python and nodejs. They have no native dependencies and should work on Lambda as well. These connectors are restricted to HANA and can't expose ABAP business logic.

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 30, 2017

@StefanScherer, I am testing on fresh new installed Ubuntu server images and on standard Windows images and no errors happen there.

Regarding libstdc error, could it be that the library is missing on Linux container: https://askubuntu.com/questions/575505/glibcxx-3-4-20-not-found-how-to-fix-this-error ?

Regarding other containers, if the standard installation fails, the build from source should help. No capacity atm. for testing on more premise and cloud containers.

@StefanScherer
Copy link

StefanScherer commented Nov 30, 2017

Thanks @bsrdjan
Well, to be honest I'm not keen on bringing additional glibc's into a container only for that thin binding layer. :-)
Yes, compiling from source might be the way to do it as we have the NW RFC SDK inside the container during build time. (I only have to find a way to suppress the download of the existing node bindings for 0.1.12.)

Just some details to the official node Docker images, they are based on Debian Jessie and have Python and GCC preinstalled to compile native bindings.

root@3c8721808c73:/tst# gcc --version
gcc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@3c8721808c73:/tst# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

@hemarangaswamy
Copy link

@ bsrdjan ; regarding the AWS Lambda question: we are able to upload custom SAP libraries into Lambda. however we are not able to use the system bin/lib folders and are running into reference issues. we would like to understand how to compile the code with local reference paths...relative paths so we can use it on Lambda...

Thank you!

@bsrdjan
Copy link
Contributor

bsrdjan commented Dec 1, 2017

@StefanScherer, which docker image exactly I could use for testing ?

@StefanScherer
Copy link

@bsrdjan I don't have a public repo available to show it, so I can roughly explain how we build a base image for our test environment.

Dockerfile for base image with SDK:

ARG node=node:6.12.0
FROM $node AS download

ARG JFROG_CREDENTIALS

RUN \
  curl -f -u ${JFROG_CREDENTIALS} -o SAPCAR_0-80000935.EXE "https://url-to/SAPCAR_617-80000935.EXE" && \
  curl -f -u ${JFROG_CREDENTIALS} -o NWRFC_38-20004565.SAR "https://url-to/NWRFC_38-20004565.SAR" && \
  chmod +x SAPCAR_0-80000935.EXE && \
  ./SAPCAR_0-80000935.EXE -xvf NWRFC_38-20004565.SAR && \
  rm SAPCAR_0-80000935.EXE && \
  rm NWRFC_38-20004565.SAR && \
  echo "/nwrfcsdk/lib" > /etc/ld.so.conf.d/saprfc.conf && \
  ldconfig

FROM $node

ENV \
  SAPRFC_VERSION=7210.0.38

COPY --from=download /nwrfcsdk /nwrfcsdk

RUN \
  echo "/nwrfcsdk/lib" > /etc/ld.so.conf.d/saprfc.conf && \
  ldconfig

This is a multi-stage Dockerfile which works fine with Docker 17.05 or newer to remove the download credentials of the first download stage. If you have the files locally, just use a COPY instruction from your host into the image instead.

I build this image with docker build --build-arg JFROG_CREDENTIALS=user:pass -t saprfc .
You can specify --build-arg node=node:8.9.1 to use the latest Node.js base image 8.9.1 instead of 6.12.0.

Then you need an application

package.json:

{
  "name": "sxmicli",
  "version": "0.0.2",
  "description": "Call SXMI functions from command line.",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "node-rfc": "0.1.12"
  }
}

app.js:

"use strict";

var rfc = require('node-rfc');

var dest = process.env.DEST || 'yourdefault';
var extCompany = process.env.EXTCOMPANY || 'yourdefault';
var extProduct = process.env.EXTPRODUCT || 'yourdefault';
var sxmiCommand = process.env.COMMAND || '';
var sxmiOptions = process.env.OPTIONS || '';

var client = new rfc.Client({ dest }, true);

console.log('Connecting to', dest);
client.connect((err) => {
  var func;
  if (err) {
    return console.error('could not connect to server', err);
  }

  console.log('Connected');
  func = client.invoke('SXMI_VERSIONS_GET', { INTERFACE: 'XOM' }, function(err, res) {
    if (err) {
      return console.error('Error invoking SXMI_VERSIONS_GET:', err);
    }

    func = client.invoke('SXMI_LOGON', {
      EXTCOMPANY: extCompany,
      EXTPRODUCT: extProduct,
      INTERFACE: 'XOM',
      VERSION: res.VERSIONS[0].VERSION
    }, function(err, res) {
      if (err) {
        return console.error('Error invoking SXMI_LOGON:', err);
      }

      var options;
      eval('options =' + sxmiOptions);
      func = client.invoke(sxmiCommand, options, function(err, res) {
        if (err) {
          return console.error('Error invoking ' + sxmiCommand + ':', err);
        }

        console.log('Result:', res);

        func = client.invoke('SXMI_LOGOFF', {
          INTERFACE: 'XOM'
        }, function(err, res) {
          if (err) {
            return console.error('Error invoking SXMI_LOGOFF:', err);
          }
        });
      });
    });
  });
});

Add a sapnwrfc.ini.

Dockerfile for the app:

FROM saprfc

WORKDIR /code
COPY package.json /code/package.json

RUN npm install --production

COPY . /code

CMD ["node", "app.js"]

I use a small helper bash script to run this container

sxmicli.sh:

#!/bin/bash
export COMMAND=$1
export OPTIONS=$2

docker run -e COMMAND -e OPTIONS --rm -it plossys/sxmicli

You can run it eg.

$ ./sxmicli.sh RSPO_SXOMS_VERSION "{}"
module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /code/node_modules/node-rfc/build/rfc/rfc.node)
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/code/node_modules/node-rfc/index.js:6:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

@StefanScherer
Copy link

StefanScherer commented Dec 1, 2017

I did this hacky Dockerfile to force compilation by blocking requests to github.com:

FROM saprfc

WORKDIR /code
COPY package.json /code/package.json

#RUN npm install --production
# poor man's solution to compile node-rfc from source
RUN cp /nwrfcsdk/include/* /usr/include && \
    cp /nwrfcsdk/lib/* /usr/lib && \
    echo "127.0.0.1 github.com" >>/etc/hosts && \
    npm install --production

COPY . /code

CMD ["node", "app.js"]

This really should be considered as a quick hack to test if compilation works.

@bsrdjan
Copy link
Contributor

bsrdjan commented Dec 1, 2017

Thanks @StefanScherer, will check that.

@PrakashSadasivam, is there perhaps a docker image for local testing AWS Lambda as well? Can you eventually provide the configuration?

I opened new issue for this, let please continue there: #40 .

@PrakashSadasivam
Copy link

@StefanScherer , I am working on building docker image for SAP node-rfc, if you have it build can you please share the docker file?

@bsrdjan
Copy link
Contributor

bsrdjan commented Dec 5, 2017

@StefanScherer,

Using your node-rfc docker container (minor adaptation) I had no issued while building from source for node-rfc 0.12:

FROM node:8

ENV SAPNWRFC_HOME /nwrfcsdk
ENV LD_LIBRARY_PATH $SAPNWRFC_HOME/lib

# copy nwrfcsdk folder from files to image
COPY files /

WORKDIR /code
COPY package.json package.json
COPY app.js app.js

RUN npm install --build-from-source node-rfc

CMD ["node", "app.js"]

When the issue with libc exactly happens ?

@StefanScherer
Copy link

@bsrdjan Thanks for --build-from-source, I have updated my Dockerfile.

The problem occurs when you just use npm install --production and let npm install the precompiled Linux bindings from github releases. Installation works without a problem, but when you run the app it will show an glibc error.

@bsrdjan
Copy link
Contributor

bsrdjan commented Dec 5, 2017

The standard docker image is shipped with older GLIBCXX version, causing issues also with other npm modules. The --production flag should not be used with this image, only build from source works.

Here how to login to docker node image shell:

docker run -v $(pwd):/root -it node-rfc:docker /bin/bash

and check GLIBC version:

root@4091f79fd5ea:/code# ldd --version
ldd (Debian GLIBC 2.19-18+deb8u10) 2.19

@bsrdjan bsrdjan closed this as completed Mar 19, 2018
@manishvyas1911
Copy link

To deploy node-rfc on lambda with NWRFCSDK libs
https://www.youtube.com/watch?v=rhY4jVtl0k8&t=39s

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

7 participants