dkackman / chia-repl

A REPL tool for Chia
Apache License 2.0
22 stars 4 forks source link

[BUG] Uncaught SyntaxError: await is only valid in async function #15

Closed kimsk closed 2 years ago

kimsk commented 2 years ago

I try Connecting and Calling a Node Function but got the error, Uncaught SyntaxError: await is only valid in async function

chia-repl/src on  main is 📦 v0.11.1 via  v14.17.4
❯ npm start

> chia-repl@0.11.1 start
> node index.js

🌿 Welcome to Chia!
Type .help or .more-help to get started
🌿 .connect
Connecting to wss://localhost:55400...
Connected
🌿 await chia.full_node.get_network_info()
await chia.full_node.get_network_info()
^^^^^

Uncaught SyntaxError: await is only valid in async function
❯ git log --oneline -n 5
e757c74 (HEAD -> main, origin/main, origin/HEAD) Merge pull request #13 from dkackman/dependabot/npm_and_yarn/src/jshint-2.13.5
c0a8c3f Bump jshint from 2.13.4 to 2.13.5 in /src
95cbaa8 move editorconfig
28e46da create settings files if not found
98d1393 Merge branch 'main' of https://github.com/dkackman/chia-repl
dkackman commented 2 years ago

I cannot reproduce that. Does it happen with any rpc call?

What version of node do you have installed? node --version Top level await was added in a later release.

kimsk commented 2 years ago

Thanks! It's been a while since I touch JS or TS. My node version was v14.17.4.

This works now with node v16.16.0!

FYI, I got hard error, Error while loading BLS module, when using v18.5.0.

image

dkackman commented 2 years ago

Error while loading BLS module, when using v18.5.0.

I stick with the LTS version for everything, so not super surprised. Keep the feedback coming. Hope you find this useful!