Skip to content

SyntaxError: Cannot use import statement outside a module in 1-consume-promise.ts #2

Description

@terence4444

Hello,

Thanks for the informative video and this demo.

Unfortunately there is an error: SyntaxError: Cannot use import statement outside a module when I tried executing 1-consume-promise.ts with command line node .\1-consume-promise.ts

As a beginner I am not able to figure out what's the root cause.
It looks like the import style is not supported by default...
I replaced the import line to require('node-fetch'); as those in other code samples and it worked.

My environment:

  • Windows 10 Version 10.0.19043.1237
  • Node v14.18.0 LTS
  • Code executed in VSCode

Thanks & best regards,

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions