question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ERROR] Must use import to load ES module

See original GitHub issue

Issue description

image

Context

Totally new Node project with typescript, @types/node, and ts-node-dev packages installed. I only get this error when I set type: "module" in package.json.

ts-node-dev: ^2.0.0

OS version (is it docker or host?), ts-node-dev version

Did you try to run with ts-node?

Did you try to run with --files option enabled?

Did you try to run with --debug option enabled?

Do you have a repro example (git repo) with simple steps to reproduce your problem?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:27
  • Comments:9

github_iconTop GitHub Comments

10reactions
danlupascucommented, Jun 2, 2022

I’m having the same problem

ts-node-dev version: 2.0.0 typescript version: 4.7.2

4reactions
angelhdzmultimediacommented, Sep 11, 2022

Update

Besides it working with Babel, I achieved to make it working with nodemon and ts-node.

Install nodemon and ts-node and of course typescript, set type: "module" in package.json, and set tsconfig.json to:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "moduleResolution": "Node",
    "module": "ESNext",
    "target": "ESNext"
  }
}

And then: nodemon --exec node --loader ts-node/esm src/main.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing in Node.js: error "Must use import to load ES Module"
The problem is that Node.js does not currently support import and export natively yet. It is still experimental according ...
Read more >
Error [ERR_REQUIRE_ESM]: Must use import to load ES ...
The error Error [ERR_REQUIRE_ESM]: Must use import to load ES Module occurs for 2 main reasons a module you are importing has been...
Read more >
Error: Must use import to load ES Module · Issue #1956 - GitHub
After update GOT library to version 12.0.0 I've got an error: Error: Must use import to load ES Module: .
Read more >
Must use import to load ES Module - Help - Pipedream
Hi, suddenly my workflow started to fail with the following error: “Must use import to load ES Module”. @germanescobar you can give this...
Read more >
Getting "must use import to load ES module" when using ...
My site is skyglass.netlify.app. I have a function that works locally with netlify dev. It requires node-fetch like this: const fetch ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found