SAP / node-rfc

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

Installation problems: tried with npm and local file #252

Closed Franco-Figueredo closed 2 years ago

Franco-Figueredo commented 2 years ago

Bug description I've been struggling to install node-rfc through npm and also by using the .tgz file locally with no luck.

To Reproduce I used 'npm install node-rfc' and 'npm install node-rfc-2.6.0.tgz' having the file downloaded in my local directory but I always get the same error after some time passes.

Error log

PS C:\Users\-\nodejsap\express> npm install (node-rfc) OR (-g node-rfc-2.6.0.tgz)
npm ERR! path C:\Users\-\AppData\Roaming\npm\node_modules\node-rfc
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install -r napi || cmake-js rebuild
npm ERR! [
npm ERR!   'C:\\Program Files\\nodejs\\node.exe',
npm ERR!   'C:\\Users\\-\\AppData\\Roaming\\npm\\node_modules\\cmake-js\\bin\\cmake-js',
npm ERR!   'rebuild'
npm ERR! ]
npm ERR! prebuild-install WARN install write EPROTO AC180000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:c:\ws\deps\openssl\openssl\ssl\statem\extensions.c:908:
npm ERR! prebuild-install WARN install
npm ERR! ERR! OMG CMake is not installed. Install CMake.
npm ERR! ERR! OMG CMake is not installed. Install CMake.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\-\AppData\Local\npm-cache\_logs\2022-03-29T00_50_39_490Z-debug-0.log

Environment I am into my company's firewall but everything is configurated with its proxies. I can install other npm packages with no troubles. I've read the issue #160 but no luck following the temporary fix posted there. Also, cmake-js is already installed.

bsrdjan commented 2 years ago

Hello @Franco-Figueredo,

the standard installation works with npm install node-rfc command and CMake is not required. CMake is used only in build from source installation: https://github.com/SAP/node-rfc#download-and-installation

The installer will fetch the package from npm and pre-compiled binary for the target platform (Windows in your case), from GH release. The pre-built binaries are .tar.gz files attached to GH release: https://github.com/SAP/node-rfc/releases/tag/v2.6.0 and cannot be installed as such (npm install tar.gz)

When the binary for the target platform not found or not reachable on GH, the installer will try to build from source and invoke CMake. According to logs, something like that happens on your Windows system, perhaps because of network issue?

The offline installation works as described in Download and Installation.

Regardless of installation method, SAP NW RFC SDK binaries shall be locally installed and Windows platform requirements shall be met: https://github.com/SAP/node-rfc#requirements

Hope this help.

Franco-Figueredo commented 2 years ago

Thank you for the fast reply, @bsrdjan!

I've done what you told me but I'm still stuck. I'm creating a docker image with node-rfc in it, but at the moment of running docker build I'm getting the following error:

#12 84.89 > node-rfc@2.6.0 install
#12 84.89 > prebuild-install -r napi || cmake-js rebuild
#12 84.89
#12 86.94 prebuild-install WARN install tunneling socket could not be established, statusCode=403
#12 87.23 [
#12 87.23   '/usr/bin/node',
#12 87.23   '/usr/src/app/node-rfc/node_modules/.bin/cmake-js',
#12 87.23   'rebuild'
#12 87.23 ]
#12 87.26 info TOOL Using Unix Makefiles generator.
#12 87.26 info DIST Downloading distribution files to: /root/.cmake-js/node-x64/v16.14.2
#12 87.26 http DIST     - https://nodejs.org/dist/v16.14.2/SHASUMS256.txt
#12 87.77 ERR! OMG Request failed with status code 403
#12 87.77 ERR! OMG Request failed with status code 403
#12 87.78 npm ERR! code 1
#12 87.78 npm ERR! path /usr/src/app/node-rfc
#12 87.79 npm ERR! command failed
#12 87.79 npm ERR! command sh -c prebuild-install -r napi || cmake-js rebuild
#12 87.79
#12 87.79 npm ERR! A complete log of this run can be found in:
#12 87.79 npm ERR!     /root/.npm/_logs/2022-03-29T18_16_16_759Z-debug-0.log

The idea is to install node-rfc locally in the docker instance. For that, I've preinstalled everything related to SAP and set the correct routes in the docker environment. Then, I've done a previous git clone of the repository as it is mentioned in the Download and Installation article, but when running the commands below the abovementioned error appears:

cd node-rfc
npm install
npm run addon
npm run ts

I see I'm getting a 403 error there but I don't know if that's the root of the problem per-se. Do you have an idea of how can I go pass through it? Any thoughts? Thank you in advance!

bsrdjan commented 2 years ago

403 indicates network access issue and the cause is hard to guess without inspecting your docker script. Could be network settings, user permissions ...

Here are few working containers with node-rfc and SAP NWRFC SDK (must be provided separately):

https://github.com/SAP/fundamental-tools/tree/main/docker

You could first try to get one of them running in your environment, to exclude or fix access issues. Then modify the script per your requirements.

Franco-Figueredo commented 2 years ago

Sorry about not posting my docker script. Here it is:

FROM -/nodejs:latest

ENV http_proxy http://ip:port/
ENV https_proxy http://ip:port/

# Set root as user for installing linux dependencies
USER root

# Prerequisites
RUN apt-get -y update && apt-get install -y unzip

ARG SAPNWRFC=sap.zip
ARG SAPNWRFC_ROOT=/usr/sap/
ENV SAPNWRFC_HOME=$SAPNWRFC_ROOT/nwrfcsdk
COPY prerequisites/$SAPNWRFC $SAPNWRFC_ROOT
RUN cd $SAPNWRFC_ROOT && \
    unzip $SAPNWRFC && \
    rm -f $SAPNWRFC && \
    echo "$SAPNWRFC_HOME/lib" > /etc/ld.so.conf.d/nwrfcsdk.conf && \
    ldconfig /usr/local/lib
ENV PATH="$PATH:$SAPNWRFC_HOME/lib"

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
COPY package-lock.json /usr/src/app/
RUN npm ci

COPY prerequisites/node-rfc.zip /usr/src/app/

RUN unzip node-rfc.zip && \
    cd node-rfc && \
    npm install && \
    npm run addon && \
    npm run ts

# Bundle app source
ENV NODE_ENV production
COPY . /usr/src/app/

# Clear the cache
RUN npm cache clean --force

EXPOSE 5000
CMD [ "node", "index.js" ]

Note that I've downloaded node-rfc repository and I have it as a .zip. Git was also giving me some headaches with proxy issues.

I've tried again running npm install --verbose node-rfc and detected that the proxy I'm using is correct and that I can install every other library except for node-rfc. The proxy log is:

npm ERR! prebuild-install http request Proxy setup detected (Host: xx, Port: xx, Authentication: Yes) Tunneling with httpsOverHttp
npm ERR! prebuild-install WARN install unable to get local issuer certificate

I don't know what else could I be missing. My certificates are also propertly installed.

bsrdjan commented 2 years ago

Perhaps this helps npm config set strict-ssl false, from https://stackoverflow.com/questions/36494336/npm-install-error-unable-to-get-local-issuer-certificate

Here one working node based docker container: SAP/fundamental-tools/docker/node-rfc.Dockerfile

Franco-Figueredo commented 2 years ago

Seems it was a proxy problem. I still can't install it through npm but I've managed to download and install it locally. What helped me was this answer: https://github.com/SAP/node-rfc/issues/166#issuecomment-681901627. Thank you for your help!