SAP / node-rfc

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

Can't install node-rfc, running out of memory. Error 134 #166

Closed GutberletJonas closed 3 years ago

GutberletJonas commented 4 years ago

Hello everyone,

I'm trying to install node-rfc for about two weeks now and keep failing, so I guess I need your help.

A little bit of background: I'm working on a enterprise server, behind a proxy. I'm using jfrog artifactory to use npm. my node version is: 14.8.0 npm version: 6.14.7

I got the installation so far to show:

`C:>npm install node-rfc

node-rfc@2.1.0 preinstall C:\node_modules\node-rfc npm install cmake-js prebuild-install prebuild node-addon-api

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm notice created a lockfile as package-lock.json. You should commit this file.

5 packages are looking for funding run npm fund for details

node-rfc@2.1.0 install C:\node_modules\node-rfc prebuild-install --tag-prefix -r napi || cmake-js rebuild

prebuild-install WARN install getaddrinfo ENOTFOUND github.com [ 'C:\Program Files\nodejs\node.exe', 'C:\node_modules\node-rfc\node_modules\cmake-js\bin\cmake-js', 'rebuild' ] info TOOL Using Visual Studio 16 2019 generator. info CMD CLEAN info RUN cmake -E remove_directory "C:\node_modules\node-rfc\build" info CMD CONFIGURE`

The installation takes really long (>20mins) and then aborts with attached error output. Apparently it is a memory allocation error, so I increased the RAM of the server and granted node more memory with set NODE_OPTIONS=--max_old_space_size=4096 This only led to the installation consuming 4 GB instead of 2GB and taking twice as long before aborting with the same error. So I guess there must be something else off.

Attached is the complete log. Thank you in advance! 2020-08-19T14_40_33_018Z-debug.log

bsrdjan commented 4 years ago

The installation does not require much RAM. The problem is apparently something else but can't reproduce on plain Windows.

Maybe this can help: https://stackoverflow.com/questions/42308879/how-to-solve-npm-error-npm-err-code-elifecycle ?

GutberletJonas commented 4 years ago

None of those helped me either... Maybe I should try to do a clean installation of node and npm

bsrdjan commented 4 years ago

Comparing your log with the log of successful installation on Windows, I see in your log that node-red admin somehow interferes with the installation.

How the package.json looks like before the node-rfc installation?

The installation command is npm install node-rfc correct?

You could eventually try:

  1. Create an empty test folder with dependency-free package.json and install the node-rfc first there:
$ cd test
$ npm init -y
$ npm i --save --timing node-rfc
  1. Add other packages and see if and when the problem starts
GutberletJonas commented 4 years ago

Hello again, so I tried what you told me and it took me a big step ahead.

Now I'm running into another issue. Apparently, CMake is unable to rename (or move) a file. I tried running cmd both as normal and as admin user, both didn't work. Following you see the console output. The npm doesn't look interesting, since everything worked there. Do you have any idea what I could do here?

`Not searching for unused variables given on the command line. -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.17763. -- The C compiler identification is MSVC 19.27.29111.0 -- The CXX compiler identification is MSVC 19.27.29111.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done Downloading node-v14.8.0-headers.tar.gz to D:/RFC-Test/node_modules/node-rfc/build/node-v14.8.0-headers.tar.gz ... CMake Error at CMakeLists.txt:78 (file): file RENAME failed to rename

D:/RFC-Test/node_modules/node-rfc/build/node-v14.8.0/include

to

C:\Users\dil-nodered-01\AppData\Roaming\npm/include

because: No such file or directory

SAP NWRFC SDK: -- Configuring incomplete, errors occurred! See also "D:/RFC-Test/node_modules/node-rfc/build/CMakeFiles/CMakeOutput.log". ERR! OMG Process terminated: 1 npm WARN RFC-Test@1.0.0 No description npm WARN RFC-Test@1.0.0 No repository field.

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-rfc@2.1.0 install: prebuild-install --tag-prefix -r napi || cmake-js rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-rfc@2.1.0 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! C:\Users\dil-nodered-01\AppData\Roaming\npm-cache_logs\2020-08-25T07_12_14_640Z-debug.log`

bsrdjan commented 4 years ago

For some reason the build from source is triggered on your Windows platform. It should not happen on Windows, the pre-compiled binary should be fetched from node-rfc GH release.

The build from source requires NodeJS include headers, which are not a part of the node runtime on Windows. The CMake tries to download them and something gets wrong during that process. Does the directory C:\Users\dil-nodered-01\AppData\Roaming\npm exist and what is the output of these two commands on your system:

C:> npm -g prefix

C:> npx envinfo

To get around this download and rename issue, you can try:

  1. Download the node headers for your node version 14.8.0 https://nodejs.org/download/release/v14.8.0/node-v14.8.0-headers.tar.gz and unpack them in some folder. The unpacked directories should look like:
/Downloads/node-v14.8.0
└── include
    └── node
  1. Set the environment variable NODE_HEADERS_INCLUDE_DIR to the full path to include folder (the path must end with include)

Now the CMake should take the headers from that location and not try to download and rename.

GutberletJonas commented 4 years ago

Thank you for your answer, following the outputs: `D:\RFC-Test>npm -g prefix C:\Users\dil-nodered-01\AppData\Roaming\npm

D:\RFC-Test>npx envinfo npx: installed 1 in 6.918s

System: OS: Windows 10 10.0.17763 CPU: (2) x64 Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Memory: 3.06 GB / 8.00 GB Binaries: Node: 14.8.0 - D:\Program Files\nodejs\node.EXE npm: 6.14.7 - D:\Program Files\nodejs\npm.CMD Utilities: CMake: 3.18.2 Databases: MySQL: undefined - C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.EXE Browsers: Chrome: 84.0.4147.135 Internet Explorer: 11.0.17763.771`

The changes you suggested seem to have worked. I'm sorry to tell it still doesn't work all the way. The new error log is:

`info CMD BUILD info RUN cmake --build "D:\RFC-Test\node_modules\node-rfc\build" --config Release Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved.

Checking Build System Building Custom Rule D:/RFC-Test/node_modules/node-rfc/CMakeLists.txt Client.cc D:\RFC-Test\node_modules\node-rfc\src\Client.h(9,10): fatal error C1083: Cannot open include file: 'uv.h': No such file or directory [D:\RFC-Test\node_modules\node-rfc\build\sapnwrfc.vcxproj] nwrfcsdk.cc D:\RFC-Test\node_modules\node-rfc\node_modules\node-addon-api\napi.h(4,10): fatal error C1083: Cannot open include file : 'node_api.h': No such file or directory [D:\RFC-Test\node_modules\node-rfc\build\sapnwrfc.vcxproj] Pool.cc D:\RFC-Test\node_modules\node-rfc\src\Pool.h(9,10): fatal error C1083: Cannot open include file: 'uv.h': No such file o r directory [D:\RFC-Test\node_modules\node-rfc\build\sapnwrfc.vcxproj] Throughput.cc D:\RFC-Test\node_modules\node-rfc\node_modules\node-addon-api\napi.h(4,10): fatal error C1083: Cannot open include file : 'node_api.h': No such file or directory [D:\RFC-Test\node_modules\node-rfc\build\sapnwrfc.vcxproj] Server.cc D:\RFC-Test\node_modules\node-rfc\src\Server.h(8,10): fatal error C1083: Cannot open include file: 'uv.h': No such file or directory [D:\RFC-Test\node_modules\node-rfc\build\sapnwrfc.vcxproj] addon.cc D:\RFC-Test\node_modules\node-rfc\src\Client.h(9,10): fatal error C1083: Cannot open include file: 'uv.h': No such file or directory [D:\RFC-Test\node_modules\node-rfc\build\sapnwrfc.vcxproj] ERR! OMG Process terminated: 1`

I'd be very thankful for even more help

bsrdjan commented 4 years ago

The log shows few errors:

  1. The npm -g prefix points to npm in C:\Users\dil-nodered-01\AppData\Roaming folder and the npm envinfo points to npm in D:\Program Files\nodejs ? Why there are two npms in your system and which one should be used? Can you check paths and ensure one npm used on your system?

  2. What is the value of NODE_HEADERS_INCLUDE_DIR env variable ? The log shows C1083: Cannot open include file: 'uv.h' The uv.h should be in NODE_HEADERS_INCLUDE_DIR/node folder. Is it there?

GutberletJonas commented 4 years ago

To the second question: D:\>set NODE_HEADERS_INCLUDE_DIR NODE_HEADERS_INCLUDE_DIR=C:\Users\dil-nodered-01\Downloads\node-v14.8.0-headers\node-v14.8.0\include

To the first question, I am not able to only install npm at one location. Apparently, the one in Appdata is the "global" (-g) npm and the other one is the local instance. Unfortunately I seem to need the global instance to run node-red. As soon as I rename the npm folder in D:\Program Files\nodejs, I cannot use npm anymore. So it looks like this is the instance being used. So unfortunately I am still stuck despite another 5 hours of work to try get this double installation fixed yesterday. I reinstalled nodejs, tried runnong the installation of node-rfc in different paths, etc.

bsrdjan commented 4 years ago

Using the node version manager helps avoid exactly these collisions. It is described in node-red documentation: https://nodered.org/docs/getting-started/windows and recommended also by Microsoft: https://docs.microsoft.com/en-us/windows/nodejs/setup-on-windows

Uninstal everything and ensure no node or npm are on PATH. Install the nvm and using nvm install the node version required for node-red. Then install the node-red using the 2nd (nvm) alternative method, as described in node-red documentation.

GutberletJonas commented 4 years ago

Soo, I installed nvm and got node-red working like a charm, but am still running into the same problem as before. Both npm -g prefix and npx envinfo now output the same path, so that is fixed. Thanks btw for pointing me towards nvm, it's a neat tool. Do I have to add something else to the path to resolve this problem?

bsrdjan commented 4 years ago

Which problem exactly is happening now, could you please post the log?

If include files are not found again, the cause is the bug in CMakeLists.txt, discovered and fixed yesterday: #167

In that case, you can wait for the next release, including this fix or download and unpack the node-rfc repository in some local folder (fix is already in master) and install it from there, not from npm.

Something like:

PS C:\test> Invoke-WebRequest https://github.com/SAP/node-rfc/archive/master.zip -OutFile C:\temp\noderfc-master
# unpack the zip 
PS C:\test> npm install C:\temp\noderfc-master
GutberletJonas commented 4 years ago

That seems to have fixed it! Thanks again for all the effort

bsrdjan commented 4 years ago

Glad to hear. Can you confirm if the node-rfc works well with node-red on Windows ?

Eventually comment in #161, if you see something what could eventually help?

GutberletJonas commented 4 years ago

Unfortunately I will stop working on this topic tomorrow, since I'm leaving the company, maybe my colleague will comment or I find the time to work on it in my free time

bsrdjan commented 4 years ago

Ok and thanks anyway. Please feel free to close the issue if you want and we can reopen if any updates.

vinibiscolla commented 2 years ago

Hi @bsrdjan how are you doing ?

I'm basically facing the same problem from GutberletJonas, what i am supposed to do ? open a new ticket request, or keep here ?

Thanks a lot. Kind Regards

bsrdjan commented 2 years ago

Hi @vinibiscolla,

the thread is bit older, could you please let me know what is exactly the issue and on which platform it occurs?

The node-red platform is not supported, see https://github.com/SAP/node-rfc/issues/161#issuecomment-678463099.

Kind regards, Srdjan