Skip to content
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

Await errors on fresh install #20

Open
kevintayloruk opened this issue Sep 21, 2022 · 0 comments
Open

Await errors on fresh install #20

kevintayloruk opened this issue Sep 21, 2022 · 0 comments

Comments

@kevintayloruk
Copy link

I'm probably doing something fundamentally wrong but the example code appears to throw await promise errors as documented below. All advice welcomed.

Steps to reproduce:

Install npm package:
npm i node-emberplus

Create file from example code:

const {EmberClient, EmberClientEvent, LoggingService} = require('node-emberplus');
const client = new EmberClient({host: '192.168.1.2', port: 9000, logger: new LoggingService(5)});
client.on(EmberClientEvent.ERROR, e => {
   console.log(e);
});

await client.connectAsync();
// Get Root info
await client.getDirectoryAsync();
// Get a Specific Node
let node: TreeNode = await client.getElementByPathAsync("0.0.2");
console.log(node);
// Get a node by its path identifiers
node = await client.getElementByPathAsync("path/to/node");
console.log(node);
// Expand entire tree
try {
   await client.expandAsync();
}catch(e) {
   console.log(e.stack);
};

Run:

[user-hidden]% node index.js
[full-path-hidden]/lawo-node-ember-plus/index.js:7
await client.connectAsync();
^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1027:15)
    at Module._compile (node:internal/modules/cjs/loader:1063:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Node.js v17.8.0
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

1 participant