unable to load available versions from Elastic API file
Closed this issue · 11 comments
/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)
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.
Did you install elasticsearch
package in your app?
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?
Yes, it's installed, but all modules are global. (It's in a Docker container.)
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.
const es = require('elasticsearch');
console.log(es.Client.apis);
Of course it's better. Can you open PR?
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.
Tnx. I'm almost always online and can merge and publish new version from mobile.
Travis tests cover your upcoming changes, so if you want you may send PR via online file edit 😈
Oh...that's a good idea. Thanks.
@markbirbeck please test latest version 1.7.11
Please confirm that it fixes your case.