Skip to content

unable to load available versions from Elastic API file #6

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

Closed
markbirbeck opened this issue Jul 18, 2017 · 11 comments
Closed

unable to load available versions from Elastic API file #6

markbirbeck opened this issue Jul 18, 2017 · 11 comments

Comments

@markbirbeck
Copy link

/usr/local/lib/node_modules/graphql-compose-elasticsearch/lib/ElasticApiParser.js:311
        throw new Error(`Cannot load Elastic API file with avaliable versions from ${absolutePath}`);
        ^
Error: Cannot load Elastic API file with avaliable versions from /usr/src/app/node_modules/elasticsearch/src/lib/apis/index.js
    at Function.loadApiListFile (/usr/local/lib/node_modules/graphql-compose-elasticsearch/lib/ElasticApiParser.js:311:15)
    at Function.findApiVersionFile (/usr/local/lib/node_modules/graphql-compose-elasticsearch/lib/ElasticApiParser.js:320:42)
    at new ElasticApiParser (/usr/local/lib/node_modules/graphql-compose-elasticsearch/lib/ElasticApiParser.js:55:90)
    at contextElasticClient (/usr/local/lib/node_modules/graphql-compose-elasticsearch/lib/elasticApiFieldConfig.js:71:19)
    at elasticApiFieldConfig (/usr/local/lib/node_modules/graphql-compose-elasticsearch/lib/elasticApiFieldConfig.js:39:12)
    at Object.<anonymous> (/usr/src/app/express.js:14:18)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
@markbirbeck
Copy link
Author

As you can see the path for the module that is running is /usr/local/lib/... whilst this module is looking for it in /usr/src/app/. This is because of this line:

https://github.com/nodkz/graphql-compose-elasticsearch/blob/master/src/ElasticApiParser.js#L126

which is seeking a path relative to the current directory, not the node module.

@nodkz
Copy link
Member

nodkz commented Jul 18, 2017

Did you install elasticsearch package in your app?

@markbirbeck
Copy link
Author

Would you not be better off finding the path by going relative to the elasticsearch module? Using https://nodejs.org/docs/latest/api/modules.html#modules_module_filename, for example.

Even better, is it not possible to use the ElasticSearch module itself to get the information you need?

const es = require('elasticsearch');
console.log(es.Client.apis);

Or is that information different to what you want?

@markbirbeck
Copy link
Author

Yes, it's installed, but all modules are global. (It's in a Docker container.)

@markbirbeck
Copy link
Author

So to be explicit, the /usr/local/lib path is what it should be, which as you can see in the error message is where all the other node modules are installed. But it's looking in /usr/src/app which is where the express.js file is.

@nodkz
Copy link
Member

nodkz commented Jul 18, 2017

const es = require('elasticsearch');
console.log(es.Client.apis);

Of course it's better. Can you open PR?

@markbirbeck
Copy link
Author

Ha! I might be able to, but getting a dev environment set up might be a little bit time-consuming. I'll see what I can do tomorrow.

@nodkz
Copy link
Member

nodkz commented Jul 18, 2017

Tnx. I'm almost always online and can merge and publish new version from mobile.

@nodkz
Copy link
Member

nodkz commented Jul 18, 2017

Travis tests cover your upcoming changes, so if you want you may send PR via online file edit 😈

@markbirbeck
Copy link
Author

Oh...that's a good idea. Thanks.

@nodkz nodkz closed this as completed in 1d2235c Jul 23, 2017
@nodkz
Copy link
Member

nodkz commented Jul 23, 2017

@markbirbeck please test latest version 1.7.11
Please confirm that it fixes your case.

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

2 participants