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.

ERR_UNKNOWN_FILE_EXTENSION running a basic ts file?

See original GitHub issue

Not sure what I’m doing wrong but…

node -r esbuild-runner/register helloworld.ts 
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/cjr/dev/packages/api/helloworld.ts
    at new NodeError (node:internal/errors:363:5)
    at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
    at Loader.getFormat (node:internal/modules/esm/loader:105:42)
    at Loader.getModuleJob (node:internal/modules/esm/loader:243:31)
    at Loader.import (node:internal/modules/esm/loader:177:17)
    at Object.loadESM (node:internal/process/esm_loader:68:5)

helloworld.ts:

console.log("HELLO WORLD LITERALLY!");
export default {}
node -v
> v16.3.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:21
  • Comments:8

github_iconTop GitHub Comments

5reactions
revmischacommented, Dec 19, 2021

I’m getting ERR_UNKNOWN_FILE_EXTENSION as well using esr in my ESM project, using NPM.

3reactions
codethewebcommented, Mar 13, 2022

https://github.com/antfu/esno seems to work with ES modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't run my Node.js Typescript project TypeError ...
I just resorted to using tsc --outDir out file.ts and then running ... Then Just Run the main script with this node --loader...
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 >
ts-node - npm
ERR_UNKNOWN_FILE_EXTENSION. This error is thrown by node when a module has an unrecognized file extension, or no extension at all, and is being ......
Read more >
How To Run TypeScript Scripts with ts-node - DigitalOcean
In this article you will learn how to run TypeScript scripts without the hassle of manually transpiling.
Read more >
How to Setup a TypeScript project using Rollup.js
Source Code Files. Let's create a library to perform basic Math operations and perform strings processing. The project will contain the ...
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