rodhoward / node-sybase

23 stars 55 forks source link

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

Open 6harat opened 7 years ago

6harat commented 7 years ago

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");

martvaha commented 7 years ago

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.

rodhoward commented 7 years ago

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

jayrungta commented 7 years ago

Please fix it, it is a simple path change.

ccordon01 commented 5 years ago

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

Example:

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