[ERROR] Must use import to load ES module
See original GitHub issueIssue description
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:
- Created a year ago
- Reactions:27
- Comments:9
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m having the same problem
ts-node-dev version: 2.0.0 typescript version: 4.7.2
Update
Besides it working with Babel, I achieved to make it working with
nodemon
andts-node
.Install nodemon and ts-node and of course typescript, set
type: "module"
inpackage.json
, and settsconfig.json
to:And then:
nodemon --exec node --loader ts-node/esm src/main.ts