SAP / node-rfc

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

Successful SDK installation but node cannot find the SDK NPM module. Problem on Mac M1? #263

Closed paulsabou closed 1 year ago

paulsabou commented 1 year ago

Describe the bug Successful SDK installation but node cannot find the SDK NPM module. Problem on Mac M1?

  "platform": {
    "name": "darwin",
    "arch": "arm64",
    "release": "21.6.0"
  },

To Reproduce SDK installed globally and works.

The SDK files are in the right place

ls $SAPNWRFC_HOME
/usr/local/sap/nwrfcsdk:
bin     demo        doc     fix_paths.sh    include     lib

Running the ./rfcexec returns the right results :

Error:
    Please start the program in the following way:
    rfcexec -t -a <program ID> -g <gateway host> -x <gateway service>
        -f <file with list of allowed commands> -s <allowed Sys ID>
The options "-t" (trace), "-f" and "-s" are optional.

Below further optional parameters are listed. You can find their
documentation in sapnwrfc.ini:
-on_cce <0, 1, 2> (On Character Conversion Error)
-cfit (Conversion Fault Indicator Token - the substitute symbol used if on_cce=2)
-keepalive (Sets the keepalive option. Default is 0.)
-delta <0, 1> (default 1, i.e. use delta-manager)
-no_compression (table compression, default is 0, i.e. compression is on)

The NPM package is available globally. Running npm -g list I get

├── cmake-js@6.3.2
├── corepack@0.10.0
├── node-addon-api@5.0.0
├── node-rfc@2.7.0
├── npm@8.11.0
├── pnpm@7.8.0
├── prebuild-install@7.1.1
└── prebuild@11.0.4

Environment Running node -p "require('node-rfc').environment" I get

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'node-rfc'
Require stack:
- /usr/local/sap/nwrfcsdk/bin/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at [eval]:1:1
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at node:internal/process/execution:76:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:75:60) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/sap/nwrfcsdk/bin/[eval]' ]
}
paulsabou commented 1 year ago

This is simply an issue with NODE not knowing where to look to find the globally installed modules. This Stackoverflow thread explains the issue in more depth.

bsrdjan commented 1 year ago

Please consider the node-rfc is not supported on M1