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.

ESM – TypeError [ERR_UNKNOWN_FILE_EXTENSION]

See original GitHub issue

I get this error when trying the typescript example with updated dependencies:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]:
    Unknown file extension ".ts" for /home/tolu/github/uvu/examples/typescript/tests/math.ts

An image for context 😄

image

Single tests files can be run via:

node --loader ts-node/esm test/math.ts

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lukeedcommented, Nov 30, 2020

Hey, thanks!

What if the fix was to always use require/CommonJS mode if any -r/--require flag was defined?

As touched on here, ESM Node has --loader instead, and AFAIK cannot be hooked in outside of invoking node directly. And all require hooks need access to require.extensions (internal) in order to trigger X on loaded files.

1reaction
lukeedcommented, Dec 1, 2020

OK. The first “half” of the fix is now available in 0.5.1

If you still experience this issue after upgrading, please leave some information here so that it can reproduced! Hopefully it’s been resolved fully, but my suspicion that we’ve not seen the end of it… yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't run my Node.js Typescript project TypeError ...
Can't run my Node.js Typescript project TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/App.ts · Ask Question.
Read more >
Error: unknown file extension .ts · Issue #1062 - GitHub
When I try to execute a typescript file I get the following error message: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ...
Read more >
typeerror [err_unknown_file_extension]: unknown file extension
The real cause is due to the new specification on ESM support. That is, the file that contains #!/usr/bin/env node requires an extension...
Read more >
Unknown file extension ".json" : r/vuejs - Reddit
But I got another type of error. TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: needs an import assertion of type "json".
Read more >
Troubleshooting | ts-node - TypeStrong · GitHub
This error is thrown by node when a module has an unrecognized file extension, or no extension at all, and is being executed...
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