ESM – TypeError [ERR_UNKNOWN_FILE_EXTENSION]
See original GitHub issueI 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 😄
Single tests files can be run via:
node --loader ts-node/esm test/math.ts
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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 invokingnode
directly. And all require hooks need access torequire.extensions
(internal) in order to trigger X on loaded files.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