Skip to content

Getting a syntax error when trying to run example typescript file #1051

Description

@JonoSuave

I edited the team-as-user.ts file and tried to run the following from the typescript directory (i.e. node team-as-user/team-as-user.ts):
import { Dropbox } from "dropbox";

const accessToken =
"sl.****";

const dbx = new Dropbox({ accessToken });
dbx
.teamMembersList({
limit: 500,
include_removed: false,
})
.then((data) => {
console.log(data);
});

I got the following error:
import { Dropbox } from "dropbox";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runimport { Dropbox } from "dropbox";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)

I also ran npm run build successfully and still the same error. What am I doing wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions