node-sybase icon indicating copy to clipboard operation
node-sybase copied to clipboard

Unable to find JavaSybaseLink.jar using process.env.PWD

Open 6harat opened this issue 7 years ago • 4 comments

process.env.PWD is domain specific and might not return the correct value everywhere and is also assuming that the main/index.js of an application would be present at the same level as the node_modules folder.

var PATH_TO_JAVA_BRIDGE1 = process.env.PWD + "/node_modules/sybase/JavaSybaseLink/dist/JavaSybaseLink.jar";

When I was trying to run it on windows, the process.env.PWD was returned as undefined.

As you have already put a comment in the src code over that line, //FIXME: this is bad should be a way to expose this jar file in the npm package //so that it can be called properly from parent packages.

I would suggest using the following syntax: var path = require("path"); var PATH_TO_JAVA_BRIDGE1 = path.join(__dirname, "..", "/JavaSybaseLink/dist/JavaSybaseLink.jar");

6harat avatar Mar 19 '17 11:03 6harat

For me the current path solution caused problems when node-sybase was used in a project, lets call it project A, and then another project needed to use project A. I suggested a similar solution some time ago, but I don't know whether it has any drawbacks.

martvaha avatar Mar 19 '17 12:03 martvaha

Yeah sorry must have missed that suggestion a while back. I'll try and fix that soon.

rodhoward avatar Mar 19 '17 21:03 rodhoward

Please fix it, it is a simple path change.

jayrungta avatar Aug 18 '17 17:08 jayrungta

Add this process.env.PWD = __dirname; before importing the sybase module.

Example:

process.env.PWD = __dirname;
const sybase = require('sybase');

ccordon01 avatar Nov 29 '18 17:11 ccordon01