huggingface / node-question-answering

Fast and production-ready question answering in Node.js
Apache License 2.0
464 stars 55 forks source link

SyntaxError: await is only valid in async function #18

Open JBX028 opened 4 years ago

JBX028 commented 4 years ago

Hi,

I have seen another person who created an issue for the same error recently, but despite everything I tried, I continue to receive this error:

node v12.16.2 npm 6.14.5

any idea??

yashkim77 commented 4 years ago

I get the same issue as @JBX028

node v12.18.2 npm 6.14.5

thanks in advance

JBX028 commented 4 years ago

I think npm install question-answering@latest doesn't install the full package for some reasons. I am having an other issue by trying to install a french model:

npx question-answering download flaubert/flaubert_large_cased Cannot find module '../dist/utils' Require stack:

EddieOne commented 4 years ago
async function start() {
  await someAyncFunc();
}

start();

Cannot find module '../dist/utils'

This has something to do with 2.x to 3.x migration. The filenames changed I believe. It still works in 2.x

yashkim77 commented 4 years ago

@EddieOne Thanks

fIa5h commented 4 years ago

Instead of this:

const qaClient = await QAClient.fromOptions(); const answer = await qaClient.predict(question, text); console.log(answer); // { text: 'Denver Broncos', score: 0.3 }

Try this:

QAClient.fromOptions().then(function(qaClient){ qaClient.predict(question, text).then(function(answer){ console.log(answer); // { text: 'Denver Broncos' score: 0.3 } }); });