node-question-answering icon indicating copy to clipboard operation
node-question-answering copied to clipboard

SyntaxError: await is only valid in async function

Open JBX028 opened this issue 5 years ago • 5 comments

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??

JBX028 avatar Jul 04 '20 21:07 JBX028

I get the same issue as @JBX028

node v12.18.2 npm 6.14.5

thanks in advance

yashkim77 avatar Jul 07 '20 10:07 yashkim77

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:

JBX028 avatar Jul 07 '20 12:07 JBX028

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

EddieOne avatar Jul 21 '20 15:07 EddieOne

@EddieOne Thanks

yashkim77 avatar Jul 22 '20 04:07 yashkim77

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

fIa5h avatar Sep 30 '20 07:09 fIa5h