SAP / node-rfc

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

'napi_object_freeze': identifier not found #281

Closed Berdmanfolk closed 1 year ago

Berdmanfolk commented 1 year ago

Hello! I have a problem with compilation. Unfortunately, when compiling I get these errors all the time. What can this be caused by and how to fix it?

To Reproduce Use Windows 10 x64 . Install Visual C++ redistributable 2013 x64. Install SAP NW RFC SDK 7.50 (750 Patch Level 10). Install node.js LTS 18 (18.14.2) along with tooling. Set SAPNWRFC_HOME=c:\nwrfcsdk. Add c:\nwrfcsdk\lib to the PATH. Check that rfcexec (c:\nwrfcsdk\bin\rfcexec.exe) runs without errors. Install Visual Studio 2022 for C++ build. Follow the alternative installation instructions (git clone, npm install, npm run addon). Build errors out with: 'napi_object_freeze': identifier not found.

Screenshots

scr1 scr2 scr3 scr4

bsrdjan commented 1 year ago

The NodeJS headers (include files) could be missing on your system. It depends on NodeJS installation method whether the headers are installed or not and when not installed, the build script will try to download them.

If the download fails, because of network or missing authorisation for example, no error is raised. The build process continues and fails during build. Perhaps an error message could be added here: https://github.com/SAP/node-rfc/blob/main/CMakeLists.txt#L66

If NodeJS is installed by Windows installer on your system, the header files are probably not installed. The build script will download them but can't save them because of Administrator rights missing.

You can try to open Command Prompt with "Run As Administrator and start the build with Admin rights.

Alternative is to use nvm-windows or similar utility, which downloads nodejs and headers, to standard user folder, without admin rights. Even when headers missing, the build script will download and save them to user folder.

You can also manually copy the headers to location where they should be. When you unpack node-v18.14.2-win-x64.zip from https://nodejs.org/dist/v18.14.2/, the headers are not in package and can be separately downloaded from the same location: node-v18.14.2-headers.tar.gz. To find out where to put them, you can unpack nodejs-18.14.2 for ARM for example and look for include folder.

More comfortable way is keeping nodejs in user folder and let the build script download the headers when not already installed. Hope one of these methods works for you.

You can also consider SAP NWRFC SDK upgrade to 7.50.11

Berdmanfolk commented 1 year ago

Thanks for the information @bsrdjan , it turned out that along the indicated path (C:\Users\User\Appdata\Roaming\NPM\Include) there was headers of the last version.