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

Getting Error: sapnwrfc.node is not a valid Win32 application. #284

Closed
CodingQueries2023 opened this issue Mar 30, 2023 · 29 comments
Closed
Assignees
Labels

Comments

@CodingQueries2023
Copy link

Describe the bug
I have 64 bit node js installed on my system and have installed 64 bit NWRFC SDK but I am still getting the error "\?\C:...\node_modules\node-rfc\lib\binding\sapnwrfc.node is not a valid Win32 application".

To Reproduce
Describe how the node-rfc is installed, like locally or globally and using npm install or build from source.
I have installed node-rfc locally from https://www.npmjs.com/package/node-rfc , using the command "npm i node-rfc".

envinfo

echo2

version

Environment

  • The output of node -p "require('node-rfc').environment"

node-rfc

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 30, 2023

The output of node -p "require('node-rfc').environment" shows that SAP NWRFC SDK "lib" folder is apparently not on PATH. The loader can't therefore find and load SAP NWRFC libraries.

"nwrfcsdk_lib_on_path": false

It should be fixed by adding c:\nwrfcsdk\lib to PATH, as described in installation#windows

@bsrdjan bsrdjan self-assigned this Mar 30, 2023
@CodingQueries2023
Copy link
Author

Thank you for your reply. The PATH in the environment variable shows as -
image
But the error still exists.

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 30, 2023

Can you do the following test and post the output

cd \nwrfcsdk\bin
rfcexec

@CodingQueries2023
Copy link
Author

After running the command I am getting a pop-up which says "The code execution cannot proceed because MSVCP120.dll was not found. reinstalling the program may fix this problem".

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 30, 2023

Microsoft C Runtime DLLs version 12.0 (Visual C++ 2013) is a prerequisite for SAP NWRFC SDK. Is it installed on your system?

https://github.com/SAP/node-rfc#windows

@CodingQueries2023
Copy link
Author

No, I didn't have it on my system so I installed it.
And now I am getting the following output-
image

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 30, 2023

it is correct output installation.md#verify-sap-nwrfc-sdk-installation

The node-rfc should work as well :)

@CodingQueries2023
Copy link
Author

Unfortunately I am still getting the same error.
image

I also created a fresh folder and did npm init -y and then installed node-rfc but still I am getting the error.

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 30, 2023

Can you run the Windows Process monitor, to check which library exactly fails to load?

Just start the Process Monitor and run the following command to reproduce. Similar issue discussed here: #115 (comment)

node -p "require('c:\node-rfc\node_modules\node-rfc\lib\binding\sapnwrfc.node')" 

@CodingQueries2023
Copy link
Author

I am getting something like this-
image

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 31, 2023

can you find sapnwrfc.dll and any error in log? The status different from SUCCESS ?

@CodingQueries2023
Copy link
Author

I could not find the sapnwrfc.dll and apart from the SUCCESS there is only BUFFER OVERFLOW and NAME NOT FOUND.

@bsrdjan
Copy link
Contributor

bsrdjan commented Mar 31, 2023

No idea what could be the problem. Are you using standard Windows system ? Which version/edition?

I just tested as follows:

  1. Created fresh new Windows 11 Professional system, in VMare Fusion
  2. Installed Microsoft C Runtime DLLs version 12.0, install
  3. Installed nvm for Windows and using nvm installed current node 19
  4. Created test folder and tested
npm init -y
npm install node-rfc
node -p "require('node-rfc')"

Can you check if C:...\node_modules\node-rfc\lib\binding\sapnwrfc.node exists ? What is the output of direct require of that file:

cd ... to sapnwrfc.node folder
node -p "require('./sapnwrfc.node')" 

Fresh new install should work. Some users (years ago) reported that was the only solution for them after MC C++ DLLs installed after some other libraries.

@CodingQueries2023
Copy link
Author

CodingQueries2023 commented Apr 3, 2023

I am using windows 10, Version 21H2.
image

I checked and yes the file sapnwrfc.node at C:...\node_modules\node-rfc\lib\binding\sapnwrfc.node exists.

image

Below is the output of the command node -p "require('./sapnwrfc.node')" ---

image

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 3, 2023

Something is apparently wrong with the installation:

  1. nwrfcsdk_lib_on_path in environment is shown as false and should be true
  2. The sapnwrfc.node file size in File Explorer is 276 KB and on test system is 224KB

Screenshot 2023-04-03 at 14 57 15

Could you please create fresh new folder and post the full log

mkdir test
cd test
npm init -y

# show SAPNWRFC_HOME and PATH
echo $env:SAPNWRFC_HOME
echo $env:PATH 
# or echo %PATH% ...

npm install node-rfc

node -p "require('node-rfc')"

Are you using some sort of "special" Windows installation, like running in virtual machine or similar hosted environment?

Could you please also check the file type of sapnwrfc.node, using TrID or similar Windows utility ?

@CodingQueries2023
Copy link
Author

CodingQueries2023 commented Apr 4, 2023

image

image

image

Yes, I am running it on a virtual machine.

After this fresh installation -------
image

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 4, 2023

Thank you @CodingQueries2023. Could you please also post the full console output as per my last comment

mkdir test
cd test
npm init -y
npm install node-rfc

Also

Could you please also check the file type of sapnwrfc.node, using TrID or similar Windows utility ?

@CodingQueries2023
Copy link
Author

CodingQueries2023 commented Apr 4, 2023

full1

For some reason I couldn't run TrID, is there any other software that might help cause?

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 4, 2023

For some reason I couldn't run TrID, is there any other software that might help cause?

I can check, could you please attach your sapnwrfc.node file here?

Also run npm install --production node-rfc --loglevel verbose in fresh new test folder and attach the full installation log to message.

@CodingQueries2023
Copy link
Author

binding.zip
fullnew1
fullnew2
fullnew3
fullnew4

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 5, 2023

sapnwrfc.node file from binding.zip is Linux executable and can't run on Windows. It causes the loading error: "sapnwrfc.node is not a valid Win32 application"

The executable file format can be determined also by prefix shown in plain text editor, like notepad.exe. The prefix of your sapnwrfc.node is ELF and for Windows it should be MZ.

sapnwrfc-node

Also the size of that Linux sapnwrfc.node differs from what is shipped in latest node-rfc release.

Your NPM is apparently configured for custom registry, getting corrupted installation package from there.

@CodingQueries2023
Copy link
Author

Thank you @bsrdjan for your reply.

I can't change the registry but is there a way to get around this and fix the issue?

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 5, 2023

only manual workaround. sapnwrfc.node executables for supported platforms are attached to node-rfc GitHub releases. You can

  1. Navigate to node-rfc latest GitHub release and download the Windows "asset" from there: node-rfc-v2.7.1-napi-v8-win32-x64.tar.gz
  2. Unpack the asset archive and replace your Linux sapnwrfc.node with sapnwrfc.node from the archive

You can also use this sapnwrfc.node.zip for Windows, for node-rfc 2.7.1

It should work but there could be also issues in case the rest of the package from custom registry is older node-rfc version, possibly incompatible with the latest sapnwrfc.node executable.

Why not install from standard registry and avoid the risk ?

@CodingQueries2023
Copy link
Author

CodingQueries2023 commented Apr 5, 2023

I followed the step 1 and I am getting the following output, I am not sure but I think it works, could you please confirm.
image

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 5, 2023

looks correct now

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 7, 2023

@CodingQueries2023, what type of virtual machine are you using and can you describe how your Windows system is hosted?

It could help other users with similar setup if we can find out why Linux binaries are fetched instead of Windows.

@CodingQueries2023
Copy link
Author

Hi @bsrdjan
On server I am getting the error RFC_COMMUNICATION_FAILURE and it is automatically trying to connect to our IP with PORT 3300, which is a wrong port. My correct PORT is 3629 but instead of 3629 it is trying to connect to 3300 and is getting failed to connect to. In my docker file I have mentioned the PORT 3629 and not 3300. Is there anything that you can suggest about the issue?

@bsrdjan
Copy link
Contributor

bsrdjan commented Jun 30, 2023

Could you please create another issue for communication error?

You can also try node-rfc pre-release 3.0.0-rc.1. The packaging is changed and node-rfc contains binaries for all platforms, not fetching them from Github any more.

@CodingQueries2023
Copy link
Author

Sure I will create a new issue for communication error

@bsrdjan bsrdjan changed the title Getting Error: \\?\C:\...\node_modules\node-rfc\lib\binding\sapnwrfc.node is not a valid Win32 application. Getting Error: sapnwrfc.node is not a valid Win32 application. Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants