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

"The specified module could not be found" when loaded in app running under IIS #139

Closed
steve-king-ky opened this issue Apr 17, 2020 · 10 comments

Comments

@steve-king-ky
Copy link

Today a test server was setup and I moved a project I'm working there. It's a Node application using Express. When I tested an endpoint it failed with:

Application has thrown an uncaught exception and is terminated:
Error: The specified module could not be found.

\\?\C:\inetpub\wwwroot\PersonnelApps\b50api\node_modules\node-rfc\lib\binding\sapnwrfc.node

 The SAP NW RFC SDK could not be loaded, check the installation: http://sap.github.io/node-rfc/install.html#sap-nw-rfc-sdk-installation
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1206:18)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\inetpub\wwwroot\PersonnelApps\b50api\node_modules\node-rfc\lib\wrapper\sapnwrfc-client.js:6:15)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\inetpub\wwwroot\PersonnelApps\b50api\node_modules\node-rfc\lib\index.js:6:10)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)

However, when I go to the command-line and run the same code that connects to SAP via node-rfc in a small .js file using it works just fine so there's something about the context of it running under IIS that's causing the issue although I've no idea.

BTW, the line: const rfc = require("node-rfc") when running in a script under IIS, is enough to cause the program to crash.

Any suggestions? This is driving me crazy...

@bsrdjan
Copy link
Member

bsrdjan commented Apr 20, 2020

Did you check prerequisites on IIS: https://github.com/SAP/node-rfc#prerequisites ?

Also if SAP NWRFC SDK is correctly installed, by running rfcexc.exe: http://sap.github.io/node-rfc/install.html#test ?

@steve-king-ky
Copy link
Author

@bsrdjan Yes, it appears to have been installed correctly. If I execute a script from the command-line that uses node-rfc it works perfect. This error only happens when executing under IIS for some reason.

@bsrdjan
Copy link
Member

bsrdjan commented Apr 20, 2020

Could it be that IIS for some reason can't access the SAP NNRFC SDK path?

To verify, I would try something like this on IIS:

// verify the IIS user
console.log(os.userInfo());
/*
{
  uid: 501,
  gid: 20,
  username: 'bsrdjan',
  homedir: '/Users/bsrdjan',
  shell: '/usr/local/bin/zsh'
}
*/

// verify SAP NWRFC SDK is on PATH
console.log(process.env.PATH)

// verify IIS can read SAP NWRFC SDK libs
// do some readfile from SAP NWRFC SDK lib here ...

@steve-king-ky
Copy link
Author

Great idea and running it led to an unusual discovery. The user has access but the value returned by process.env.PATH does NOT contain the path to nwrfcsdk - even though it's in the PATH environment variable (Windows) on both the system and the user.

Even more odd, if I run node.exe and run the following code:

process.env.PATH

I do see the path to the SDK listed. I restarted the IIS server but it still won't pull back the correct path. I'm not sure where it's pulling it from or if it's perhaps truncating the path?

@bsrdjan
Copy link
Member

bsrdjan commented Apr 20, 2020

Web servers restrict web sites' to local host paths. IIS could be configured the same way, using virtual directories etc. Perhaps this helps: https://stackoverflow.com/questions/14611015/iis7-accessing-network-share

@vullnet-kurti
Copy link

vullnet-kurti commented Jul 13, 2020

@bsrdjan
I am running in the same problem.
I downloaded windows x64 binary from here https://github.com/SAP/node-rfc/releases/tag/v1.2.0, and I'm getting the same error:

Error: The specified module could not be found.

Also if SAP NWRFC SDK is correctly installed, by running rfcexc.exe: http://sap.github.io/node-rfc/install.html#test ?

Also checked this. It is correctly installed.

This is from a simple .js file that imports node-rfc:
const rfc = require("node-rfc")

I logged process.env.PATH, and the SAP NWRFC SDK path gets listed.

Any idea why this might happen?

Thanks.

@steve-king-ky
Copy link
Author

steve-king-ky commented Jul 13, 2020 via email

@bsrdjan
Copy link
Member

bsrdjan commented Sep 3, 2020

Sorry for the longer waiting here. I don't see a difference in node-rfc version, causing the issue.

Could it be the authorisation problem? Could it be that IIS is running with another user account, which does not have access to NWRFC SDK ?

@steve-king-ky
Copy link
Author

No worries - thank you so much for your interest in this post, by the way. I do not think that was the issue. Once I paired version 1.0.0 of the node-rfc packge with the latest version of node.js it worked fine.

@bsrdjan
Copy link
Member

bsrdjan commented Sep 3, 2020

Thanks for the update, let close the issue then. I also sent one message via LinkedIn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants