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

SyntaxError: Cannot use import statement outside a module #28

Open
StErMi opened this issue Aug 14, 2022 · 1 comment
Open

SyntaxError: Cannot use import statement outside a module #28

StErMi opened this issue Aug 14, 2022 · 1 comment

Comments

@StErMi
Copy link

StErMi commented Aug 14, 2022

I'm trying to use the SDK and execute this script

import {client} from 'defi-sdk';

const BASE_URL = 'wss://api-v4.zerion.io/';

client.configure({url: BASE_URL, apiToken: 'my_token'});

client.subscribe({
  namespace: 'address',
  body: {
    scope: ['transactions'],
    payload: {
      address: 'my_address',
      currency: 'usd',
    },
  },
  onMessage: (event, data) => {
    console.log(data);
    return;
  },
});

but when I try to execute the script via npx ts-node server/zerion2.ts I get this error

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Object.require.extensions.<computed> [as .js] (/Users/zerion/node_modules/ts-node/src/index.ts:1608:43)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/zerion/server/zerion2.ts:1:1)
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

2 participants
@StErMi and others